diff options
author | kib <kib@FreeBSD.org> | 2013-09-10 05:17:53 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2013-09-10 05:17:53 +0000 |
commit | d2c56781f0a45b06fec36b63c2686686ec805f31 (patch) | |
tree | 2f2015793b7c2aa9dca176540e9448847e739b02 /sys/dev/cpuctl | |
parent | 3d2b366a366c56edb8a86a84ee95f0de06fa61a4 (diff) | |
download | FreeBSD-src-d2c56781f0a45b06fec36b63c2686686ec805f31.zip FreeBSD-src-d2c56781f0a45b06fec36b63c2686686ec805f31.tar.gz |
Call free() on the pointer returned from malloc().
Reported and tested by: Oliver Pinter <oliver.pntr@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Approved by: re (delphij)
Diffstat (limited to 'sys/dev/cpuctl')
-rw-r--r-- | sys/dev/cpuctl/cpuctl.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/dev/cpuctl/cpuctl.c b/sys/dev/cpuctl/cpuctl.c index 4e5abb2..317fc08 100644 --- a/sys/dev/cpuctl/cpuctl.c +++ b/sys/dev/cpuctl/cpuctl.c @@ -295,10 +295,10 @@ cpuctl_do_update(int cpu, cpuctl_update_args_t *data, struct thread *td) static int update_intel(int cpu, cpuctl_update_args_t *args, struct thread *td) { - void *ptr = NULL; + void *ptr; uint64_t rev0, rev1; uint32_t tmp[4]; - int is_bound = 0; + int is_bound; int oldcpu; int ret; @@ -312,10 +312,11 @@ update_intel(int cpu, cpuctl_update_args_t *args, struct thread *td) } /* - * 16 byte alignment required. + * 16 byte alignment required. Rely on the fact that + * malloc(9) always returns the pointer aligned at least on + * the size of the allocation. */ ptr = malloc(args->size + 16, M_CPUCTL, M_WAITOK); - ptr = (void *)(16 + ((intptr_t)ptr & ~0xf)); if (copyin(args->data, ptr, args->size) != 0) { DPRINTF("[cpuctl,%d]: copyin %p->%p of %zd bytes failed", __LINE__, args->data, ptr, args->size); @@ -408,10 +409,10 @@ fail: static int update_via(int cpu, cpuctl_update_args_t *args, struct thread *td) { - void *ptr = NULL; + void *ptr; uint64_t rev0, rev1, res; uint32_t tmp[4]; - int is_bound = 0; + int is_bound; int oldcpu; int ret; @@ -427,8 +428,7 @@ update_via(int cpu, cpuctl_update_args_t *args, struct thread *td) /* * 4 byte alignment required. */ - ptr = malloc(args->size + 16, M_CPUCTL, M_WAITOK); - ptr = (void *)(16 + ((intptr_t)ptr & ~0xf)); + ptr = malloc(args->size, M_CPUCTL, M_WAITOK); if (copyin(args->data, ptr, args->size) != 0) { DPRINTF("[cpuctl,%d]: copyin %p->%p of %zd bytes failed", __LINE__, args->data, ptr, args->size); |