[PATCH] two PNP memory leaks

Hollis Blanchard (hollis@austin.ibm.com)
Fri, 23 May 2003 14:20:16 -0500


--Apple-Mail-24-248489016
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed

Also caught by Stanford memory leak checker circa 2.5.48.

-- 
Hollis Blanchard
IBM Linux Technology Center

--Apple-Mail-24-248489016 Content-Disposition: attachment; filename=pnp-memleaks.diff Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="pnp-memleaks.diff"

--- 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,

--Apple-Mail-24-248489016--

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