lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.0611171224150.2261-100000@iolanthe.rowland.org>
Date:	Fri, 17 Nov 2006 12:36:57 -0500 (EST)
From:	Alan Stern <stern@...land.harvard.edu>
To:	Andrew Morton <akpm@...l.org>,
	Venkatesh Pallipadi <venkatesh.pallipadi@...el.com>,
	Jens Axboe <axboe@...nel.dk>,
	Christoph Lameter <clameter@....com>,
	Pedro Roque <roque@...fc.ul.pt>,
	"David S. Miller" <davem@...emloft.net>
cc:	"Paul E. McKenney" <paulmck@...ibm.com>,
	Kernel development list <linux-kernel@...r.kernel.org>
Subject: [PATCH] Allow NULL pointers in percpu_free

The patch (as824) 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@...land.harvard.edu>

---

Index: usb-2.6/arch/i386/kernel/acpi/cstate.c
===================================================================
--- usb-2.6.orig/arch/i386/kernel/acpi/cstate.c
+++ usb-2.6/arch/i386/kernel/acpi/cstate.c
@@ -155,10 +155,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: usb-2.6/block/blktrace.c
===================================================================
--- usb-2.6.orig/block/blktrace.c
+++ usb-2.6/block/blktrace.c
@@ -366,8 +366,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: usb-2.6/mm/allocpercpu.c
===================================================================
--- usb-2.6.orig/mm/allocpercpu.c
+++ usb-2.6/mm/allocpercpu.c
@@ -17,10 +17,9 @@
 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 (!__pdata)
+		return;
 	__percpu_depopulate_mask(__pdata, &cpu_possible_map);
 	kfree(__percpu_disguise(__pdata));
 }
Index: usb-2.6/net/ipv6/af_inet6.c
===================================================================
--- usb-2.6.orig/net/ipv6/af_inet6.c
+++ usb-2.6/net/ipv6/af_inet6.c
@@ -719,10 +719,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;
 }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ