linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] two PNP memory leaks
@ 2003-05-23 19:20 Hollis Blanchard
  0 siblings, 0 replies; only message in thread
From: Hollis Blanchard @ 2003-05-23 19:20 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 109 bytes --]

Also caught by Stanford memory leak checker circa 2.5.48.

-- 
Hollis Blanchard
IBM Linux Technology Center


[-- Attachment #2: pnp-memleaks.diff --]
[-- Type: application/octet-stream, Size: 1144 bytes --]

--- linux-2.5.69/drivers/pnp/quirks.c.orig	2003-05-15 16:53:12.000000000 -0500
+++ linux-2.5.69/drivers/pnp/quirks.c	2003-05-15 16:53:15.000000000 -0500
@@ -39,9 +39,13 @@
 	 */
 	for ( ; res ; res = res->dep ) {
 		port2 = pnp_alloc(sizeof(struct pnp_port));
+		if (!port2)
+			return;
 		port3 = pnp_alloc(sizeof(struct pnp_port));
-		if (!port2 || !port3)
+		if (!port3) {
+			kfree(port2);
 			return;
+		}
 		port = res->port;
 		memcpy(port2, port, sizeof(struct pnp_port));
 		memcpy(port3, port, sizeof(struct pnp_port));
--- linux-2.5.69/drivers/pnp/isapnp/core.c.orig	2003-05-13 14:08:02.000000000 -0500
+++ linux-2.5.69/drivers/pnp/isapnp/core.c	2003-05-13 14:08:25.000000000 -0500
@@ -419,11 +419,12 @@
 
 static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigned short device)
 {
-	struct pnp_id * id = isapnp_alloc(sizeof(struct pnp_id));
-	if (!id)
-		return;
+	struct pnp_id * id;
 	if (!dev)
 		return;
+	id = isapnp_alloc(sizeof(struct pnp_id));
+	if (!id)
+		return;
 	sprintf(id->id, "%c%c%c%x%x%x%x",
 			'A' + ((vendor >> 2) & 0x3f) - 1,
 			'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-23 19:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-23 19:20 [PATCH] two PNP memory leaks Hollis Blanchard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).