diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2006-12-06 23:32:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 11:39:22 -0500 |
commit | a120586873d3d64de93bd6d593d237e131994e58 (patch) | |
tree | ae284884e23268e867f748a2ab52353cf2390e89 | |
parent | b30973f877fea1a3fb84e05599890fcc082a88e5 (diff) |
[PATCH] Allow NULL pointers in percpu_free
The patch (as824b) makes percpu_free() ignore NULL arguments, as one would
expect for a deallocation routine. (Note that free_percpu is #defined as
percpu_free in include/linux/percpu.h.) A few callers are updated to remove
now-unneeded tests for NULL. A few other callers already seem to assume
that passing a NULL pointer to percpu_free() is okay!
The patch also removes an unnecessary NULL check in percpu_depopulate().
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/i386/kernel/acpi/cstate.c | 6 | ||||
-rw-r--r-- | block/blktrace.c | 3 | ||||
-rw-r--r-- | mm/allocpercpu.c | 9 | ||||
-rw-r--r-- | net/ipv6/af_inet6.c | 6 |
4 files changed, 10 insertions, 14 deletions
diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c index 4664b55f623..12e937c1ce4 100644 --- a/arch/i386/kernel/acpi/cstate.c +++ b/arch/i386/kernel/acpi/cstate.c | |||
@@ -156,10 +156,8 @@ static int __init ffh_cstate_init(void) | |||
156 | 156 | ||
157 | static void __exit ffh_cstate_exit(void) | 157 | static void __exit ffh_cstate_exit(void) |
158 | { | 158 | { |
159 | if (cpu_cstate_entry) { | 159 | free_percpu(cpu_cstate_entry); |
160 | free_percpu(cpu_cstate_entry); | 160 | cpu_cstate_entry = NULL; |
161 | cpu_cstate_entry = NULL; | ||
162 | } | ||
163 | } | 161 | } |
164 | 162 | ||
165 | arch_initcall(ffh_cstate_init); | 163 | arch_initcall(ffh_cstate_init); |
diff --git a/block/blktrace.c b/block/blktrace.c index 74e02c04b2d..d3679dd1d22 100644 --- a/block/blktrace.c +++ b/block/blktrace.c | |||
@@ -394,8 +394,7 @@ err: | |||
394 | if (bt) { | 394 | if (bt) { |
395 | if (bt->dropped_file) | 395 | if (bt->dropped_file) |
396 | debugfs_remove(bt->dropped_file); | 396 | debugfs_remove(bt->dropped_file); |
397 | if (bt->sequence) | 397 | free_percpu(bt->sequence); |
398 | free_percpu(bt->sequence); | ||
399 | if (bt->rchan) | 398 | if (bt->rchan) |
400 | relay_close(bt->rchan); | 399 | relay_close(bt->rchan); |
401 | kfree(bt); | 400 | kfree(bt); |
diff --git a/mm/allocpercpu.c b/mm/allocpercpu.c index eaa9abeea53..b2486cf887a 100644 --- a/mm/allocpercpu.c +++ b/mm/allocpercpu.c | |||
@@ -17,10 +17,9 @@ | |||
17 | void percpu_depopulate(void *__pdata, int cpu) | 17 | void percpu_depopulate(void *__pdata, int cpu) |
18 | { | 18 | { |
19 | struct percpu_data *pdata = __percpu_disguise(__pdata); | 19 | struct percpu_data *pdata = __percpu_disguise(__pdata); |
20 | if (pdata->ptrs[cpu]) { | 20 | |
21 | kfree(pdata->ptrs[cpu]); | 21 | kfree(pdata->ptrs[cpu]); |
22 | pdata->ptrs[cpu] = NULL; | 22 | pdata->ptrs[cpu] = NULL; |
23 | } | ||
24 | } | 23 | } |
25 | EXPORT_SYMBOL_GPL(percpu_depopulate); | 24 | EXPORT_SYMBOL_GPL(percpu_depopulate); |
26 | 25 | ||
@@ -123,6 +122,8 @@ EXPORT_SYMBOL_GPL(__percpu_alloc_mask); | |||
123 | */ | 122 | */ |
124 | void percpu_free(void *__pdata) | 123 | void percpu_free(void *__pdata) |
125 | { | 124 | { |
125 | if (unlikely(!__pdata)) | ||
126 | return; | ||
126 | __percpu_depopulate_mask(__pdata, &cpu_possible_map); | 127 | __percpu_depopulate_mask(__pdata, &cpu_possible_map); |
127 | kfree(__percpu_disguise(__pdata)); | 128 | kfree(__percpu_disguise(__pdata)); |
128 | } | 129 | } |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 87c8f54872b..e5cd83b2205 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -720,10 +720,8 @@ snmp6_mib_free(void *ptr[2]) | |||
720 | { | 720 | { |
721 | if (ptr == NULL) | 721 | if (ptr == NULL) |
722 | return; | 722 | return; |
723 | if (ptr[0]) | 723 | free_percpu(ptr[0]); |
724 | free_percpu(ptr[0]); | 724 | free_percpu(ptr[1]); |
725 | if (ptr[1]) | ||
726 | free_percpu(ptr[1]); | ||
727 | ptr[0] = ptr[1] = NULL; | 725 | ptr[0] = ptr[1] = NULL; |
728 | } | 726 | } |
729 | 727 | ||