lkml.org 
[lkml]   [2003]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH] two PNP memory leaks
From
Also caught by Stanford memory leak checker circa 2.5.48.

--
Hollis Blanchard
IBM Linux Technology Center

--- 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,
\
 
 \ /
  Last update: 2005-03-22 13:35    [from the cache]
©2003-2011 Jasper Spaans