Commit a9adb8db authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] pnp: card_probe(): fix memory leak

We can leak `clink' if drv->probe == 0.
Signed-off-by: default avatarJesper Juhl <jesper.juhl@gmail.com>
Cc: Adam Belay <ambx1@neo.rr.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 552c0348
...@@ -60,30 +60,34 @@ static void card_remove_first(struct pnp_dev * dev) ...@@ -60,30 +60,34 @@ static void card_remove_first(struct pnp_dev * dev)
card_remove(dev); card_remove(dev);
} }
static int card_probe(struct pnp_card * card, struct pnp_card_driver * drv) static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
{ {
const struct pnp_card_device_id *id = match_card(drv,card); const struct pnp_card_device_id *id;
if (id) { struct pnp_card_link *clink;
struct pnp_card_link * clink = pnp_alloc(sizeof(struct pnp_card_link)); struct pnp_dev *dev;
if (!clink)
return 0; if (!drv->probe)
clink->card = card; return 0;
clink->driver = drv; id = match_card(drv,card);
clink->pm_state = PMSG_ON; if (!id)
if (drv->probe) { return 0;
if (drv->probe(clink, id)>=0)
return 1; clink = pnp_alloc(sizeof(*clink));
else { if (!clink)
struct pnp_dev * dev; return 0;
card_for_each_dev(card, dev) { clink->card = card;
if (dev->card_link == clink) clink->driver = drv;
pnp_release_card_device(dev); clink->pm_state = PMSG_ON;
}
kfree(clink); if (drv->probe(clink, id) >= 0)
} return 1;
} else
return 1; /* Recovery */
card_for_each_dev(card, dev) {
if (dev->card_link == clink)
pnp_release_card_device(dev);
} }
kfree(clink);
return 0; return 0;
} }
......
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