Commit a120586873d3d64de93bd6d593d237e131994e58
Committed by
Linus Torvalds
1 parent
b30973f877
Exists in
master
and in
7 other branches
[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>
Showing 4 changed files with 10 additions and 14 deletions Side-by-side Diff
arch/i386/kernel/acpi/cstate.c
... | ... | @@ -156,10 +156,8 @@ |
156 | 156 | |
157 | 157 | static void __exit ffh_cstate_exit(void) |
158 | 158 | { |
159 | - if (cpu_cstate_entry) { | |
160 | - free_percpu(cpu_cstate_entry); | |
161 | - cpu_cstate_entry = NULL; | |
162 | - } | |
159 | + free_percpu(cpu_cstate_entry); | |
160 | + cpu_cstate_entry = NULL; | |
163 | 161 | } |
164 | 162 | |
165 | 163 | arch_initcall(ffh_cstate_init); |
block/blktrace.c
mm/allocpercpu.c
... | ... | @@ -17,10 +17,9 @@ |
17 | 17 | void percpu_depopulate(void *__pdata, int cpu) |
18 | 18 | { |
19 | 19 | struct percpu_data *pdata = __percpu_disguise(__pdata); |
20 | - if (pdata->ptrs[cpu]) { | |
21 | - kfree(pdata->ptrs[cpu]); | |
22 | - pdata->ptrs[cpu] = NULL; | |
23 | - } | |
20 | + | |
21 | + kfree(pdata->ptrs[cpu]); | |
22 | + pdata->ptrs[cpu] = NULL; | |
24 | 23 | } |
25 | 24 | EXPORT_SYMBOL_GPL(percpu_depopulate); |
26 | 25 | |
... | ... | @@ -123,6 +122,8 @@ |
123 | 122 | */ |
124 | 123 | void percpu_free(void *__pdata) |
125 | 124 | { |
125 | + if (unlikely(!__pdata)) | |
126 | + return; | |
126 | 127 | __percpu_depopulate_mask(__pdata, &cpu_possible_map); |
127 | 128 | kfree(__percpu_disguise(__pdata)); |
128 | 129 | } |
net/ipv6/af_inet6.c