]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] Allow NULL pointers in percpu_free
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 7 Dec 2006 04:32:37 +0000 (20:32 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Thu, 7 Dec 2006 16:39:22 +0000 (08:39 -0800)
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>
arch/i386/kernel/acpi/cstate.c
block/blktrace.c
mm/allocpercpu.c
net/ipv6/af_inet6.c

index 4664b55f623ef2b349a510c0dcd487d8149063c3..12e937c1ce4bbe11feccd1be11d75e728adc1f44 100644 (file)
@@ -156,10 +156,8 @@ static int __init ffh_cstate_init(void)
 
 static void __exit ffh_cstate_exit(void)
 {
-       if (cpu_cstate_entry) {
-               free_percpu(cpu_cstate_entry);
-               cpu_cstate_entry = NULL;
-       }
+       free_percpu(cpu_cstate_entry);
+       cpu_cstate_entry = NULL;
 }
 
 arch_initcall(ffh_cstate_init);
index 74e02c04b2dab6eb9567a49f9e589cfe69fb2e9e..d3679dd1d2201785e91194415d01736a16af54bc 100644 (file)
@@ -394,8 +394,7 @@ err:
        if (bt) {
                if (bt->dropped_file)
                        debugfs_remove(bt->dropped_file);
-               if (bt->sequence)
-                       free_percpu(bt->sequence);
+               free_percpu(bt->sequence);
                if (bt->rchan)
                        relay_close(bt->rchan);
                kfree(bt);
index eaa9abeea5364f6578c53c607d17955e3aebaef1..b2486cf887a06c1ecbd3c3d60d10682e2e5fc7d0 100644 (file)
 void percpu_depopulate(void *__pdata, int cpu)
 {
        struct percpu_data *pdata = __percpu_disguise(__pdata);
-       if (pdata->ptrs[cpu]) {
-               kfree(pdata->ptrs[cpu]);
-               pdata->ptrs[cpu] = NULL;
-       }
+
+       kfree(pdata->ptrs[cpu]);
+       pdata->ptrs[cpu] = NULL;
 }
 EXPORT_SYMBOL_GPL(percpu_depopulate);
 
@@ -123,6 +122,8 @@ EXPORT_SYMBOL_GPL(__percpu_alloc_mask);
  */
 void percpu_free(void *__pdata)
 {
+       if (unlikely(!__pdata))
+               return;
        __percpu_depopulate_mask(__pdata, &cpu_possible_map);
        kfree(__percpu_disguise(__pdata));
 }
index 87c8f54872b77fc0d3f187ca32cb1989569d6513..e5cd83b2205d41e9a2689224b12d4d8dbfaec2e9 100644 (file)
@@ -720,10 +720,8 @@ snmp6_mib_free(void *ptr[2])
 {
        if (ptr == NULL)
                return;
-       if (ptr[0])
-               free_percpu(ptr[0]);
-       if (ptr[1])
-               free_percpu(ptr[1]);
+       free_percpu(ptr[0]);
+       free_percpu(ptr[1]);
        ptr[0] = ptr[1] = NULL;
 }