Commit a1205868 authored by Alan Stern's avatar Alan Stern Committed by Linus Torvalds

[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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b30973f8
...@@ -156,10 +156,8 @@ static int __init ffh_cstate_init(void) ...@@ -156,10 +156,8 @@ static int __init ffh_cstate_init(void)
static void __exit ffh_cstate_exit(void) static void __exit ffh_cstate_exit(void)
{ {
if (cpu_cstate_entry) {
free_percpu(cpu_cstate_entry); free_percpu(cpu_cstate_entry);
cpu_cstate_entry = NULL; cpu_cstate_entry = NULL;
}
} }
arch_initcall(ffh_cstate_init); arch_initcall(ffh_cstate_init);
......
...@@ -394,7 +394,6 @@ static int blk_trace_setup(request_queue_t *q, struct block_device *bdev, ...@@ -394,7 +394,6 @@ static int blk_trace_setup(request_queue_t *q, struct block_device *bdev,
if (bt) { if (bt) {
if (bt->dropped_file) if (bt->dropped_file)
debugfs_remove(bt->dropped_file); debugfs_remove(bt->dropped_file);
if (bt->sequence)
free_percpu(bt->sequence); free_percpu(bt->sequence);
if (bt->rchan) if (bt->rchan)
relay_close(bt->rchan); relay_close(bt->rchan);
......
...@@ -17,10 +17,9 @@ ...@@ -17,10 +17,9 @@
void percpu_depopulate(void *__pdata, int cpu) void percpu_depopulate(void *__pdata, int cpu)
{ {
struct percpu_data *pdata = __percpu_disguise(__pdata); struct percpu_data *pdata = __percpu_disguise(__pdata);
if (pdata->ptrs[cpu]) {
kfree(pdata->ptrs[cpu]); kfree(pdata->ptrs[cpu]);
pdata->ptrs[cpu] = NULL; pdata->ptrs[cpu] = NULL;
}
} }
EXPORT_SYMBOL_GPL(percpu_depopulate); EXPORT_SYMBOL_GPL(percpu_depopulate);
...@@ -123,6 +122,8 @@ EXPORT_SYMBOL_GPL(__percpu_alloc_mask); ...@@ -123,6 +122,8 @@ EXPORT_SYMBOL_GPL(__percpu_alloc_mask);
*/ */
void percpu_free(void *__pdata) void percpu_free(void *__pdata)
{ {
if (unlikely(!__pdata))
return;
__percpu_depopulate_mask(__pdata, &cpu_possible_map); __percpu_depopulate_mask(__pdata, &cpu_possible_map);
kfree(__percpu_disguise(__pdata)); kfree(__percpu_disguise(__pdata));
} }
......
...@@ -720,9 +720,7 @@ snmp6_mib_free(void *ptr[2]) ...@@ -720,9 +720,7 @@ snmp6_mib_free(void *ptr[2])
{ {
if (ptr == NULL) if (ptr == NULL)
return; return;
if (ptr[0])
free_percpu(ptr[0]); free_percpu(ptr[0]);
if (ptr[1])
free_percpu(ptr[1]); free_percpu(ptr[1]);
ptr[0] = ptr[1] = NULL; ptr[0] = ptr[1] = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment