aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_kcov.c
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2019-02-19 17:03:34 +0000
committerAndrew Turner <andrew@FreeBSD.org>2019-02-19 17:03:34 +0000
commit72b66398fa7114124f4fecbaa5e04e6c205b2434 (patch)
treee5386a49e3288fb776d394799eca351b07317140 /sys/kern/kern_kcov.c
parent18a7de663bae743c421c0fac8939e1fc99873b4b (diff)
downloadsrc-72b66398fa7114124f4fecbaa5e04e6c205b2434.tar.gz
src-72b66398fa7114124f4fecbaa5e04e6c205b2434.zip
Create a common function to handle freeing the kcov info struct.
Both places that may free the kcov info struct are identical. Create a new common function to hold the code. Sponsored by: DARPA, AFRL
Notes
Notes: svn path=/head/; revision=344279
Diffstat (limited to 'sys/kern/kern_kcov.c')
-rw-r--r--sys/kern/kern_kcov.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/sys/kern/kern_kcov.c b/sys/kern/kern_kcov.c
index 84949a7296bd..121b1736ed2b 100644
--- a/sys/kern/kern_kcov.c
+++ b/sys/kern/kern_kcov.c
@@ -136,6 +136,7 @@ static d_mmap_single_t kcov_mmap_single;
static d_ioctl_t kcov_ioctl;
static int kcov_alloc(struct kcov_info *info, size_t entries);
+static void kcov_free(struct kcov_info *info);
static void kcov_init(const void *unused);
static struct cdevsw kcov_cdevsw = {
@@ -288,14 +289,7 @@ kcov_mmap_cleanup(void *arg)
* The KCOV_STATE_DYING stops new threads from using it.
* The lack of a thread means nothing is currently using the buffers.
*/
-
- if (info->kvaddr != 0) {
- pmap_qremove(info->kvaddr, info->bufsize / PAGE_SIZE);
- kva_free(info->kvaddr, info->bufsize);
- }
- if (info->bufobj != NULL && !info->mmap)
- vm_object_deallocate(info->bufobj);
- free(info, M_KCOV_INFO);
+ kcov_free(info);
}
static int
@@ -398,6 +392,19 @@ kcov_alloc(struct kcov_info *info, size_t entries)
return (0);
}
+static void
+kcov_free(struct kcov_info *info)
+{
+
+ if (info->kvaddr != 0) {
+ pmap_qremove(info->kvaddr, info->bufsize / PAGE_SIZE);
+ kva_free(info->kvaddr, info->bufsize);
+ }
+ if (info->bufobj != NULL && !info->mmap)
+ vm_object_deallocate(info->bufobj);
+ free(info, M_KCOV_INFO);
+}
+
static int
kcov_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag __unused,
struct thread *td)
@@ -531,14 +538,7 @@ kcov_thread_dtor(void *arg __unused, struct thread *td)
* The KCOV_STATE_DYING stops new threads from using it.
* It also stops the current thread from trying to use the info struct.
*/
-
- if (info->kvaddr != 0) {
- pmap_qremove(info->kvaddr, info->bufsize / PAGE_SIZE);
- kva_free(info->kvaddr, info->bufsize);
- }
- if (info->bufobj != NULL && !info->mmap)
- vm_object_deallocate(info->bufobj);
- free(info, M_KCOV_INFO);
+ kcov_free(info);
}
static void