aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/card.c
diff options
context:
space:
mode:
authorJesper Juhl <jesper.juhl@gmail.com>2006-06-25 08:47:17 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:01 -0400
commita9adb8dbcd7a337620862106f8c17aeb5e7278c7 (patch)
treec70b44cb6576c8034f52244af76a52c887146d4b /drivers/pnp/card.c
parent552c03483e49a69312c9e7384fda9282c991880a (diff)
[PATCH] pnp: card_probe(): fix memory leak
We can leak `clink' if drv->probe == 0. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Cc: Adam Belay <ambx1@neo.rr.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/pnp/card.c')
-rw-r--r--drivers/pnp/card.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index bb19c64073c..0b4adcb60df 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -60,30 +60,34 @@ static void card_remove_first(struct pnp_dev * dev)
60 card_remove(dev); 60 card_remove(dev);
61} 61}
62 62
63static int card_probe(struct pnp_card * card, struct pnp_card_driver * drv) 63static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
64{ 64{
65 const struct pnp_card_device_id *id = match_card(drv,card); 65 const struct pnp_card_device_id *id;
66 if (id) { 66 struct pnp_card_link *clink;
67 struct pnp_card_link * clink = pnp_alloc(sizeof(struct pnp_card_link)); 67 struct pnp_dev *dev;
68 if (!clink) 68
69 return 0; 69 if (!drv->probe)
70 clink->card = card; 70 return 0;
71 clink->driver = drv; 71 id = match_card(drv,card);
72 clink->pm_state = PMSG_ON; 72 if (!id)
73 if (drv->probe) { 73 return 0;
74 if (drv->probe(clink, id)>=0) 74
75 return 1; 75 clink = pnp_alloc(sizeof(*clink));
76 else { 76 if (!clink)
77 struct pnp_dev * dev; 77 return 0;
78 card_for_each_dev(card, dev) { 78 clink->card = card;
79 if (dev->card_link == clink) 79 clink->driver = drv;
80 pnp_release_card_device(dev); 80 clink->pm_state = PMSG_ON;
81 } 81
82 kfree(clink); 82 if (drv->probe(clink, id) >= 0)
83 } 83 return 1;
84 } else 84
85 return 1; 85 /* Recovery */
86 card_for_each_dev(card, dev) {
87 if (dev->card_link == clink)
88 pnp_release_card_device(dev);
86 } 89 }
90 kfree(clink);
87 return 0; 91 return 0;
88} 92}
89 93