Commit 0e621015 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] two PNP memory leaks

From: Hollis Blanchard <hollis@austin.ibm.com>

Fix two pnp error-path memory leaks, caught by Stanford memory leak checker
circa 2.5.48.
parent 1f2d5f71
......@@ -419,11 +419,12 @@ static void __init isapnp_skip_bytes(int count)
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,
......
......@@ -40,9 +40,13 @@ static void quirk_awe32_resources(struct pnp_dev *dev)
*/
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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment