Re: [PATCH][resend] fix resource leak in pnp card_probe()

From: Andrew Morton
Date: Sun May 14 2006 - 06:01:33 EST


Keith Owens <kaos@xxxxxxxxxx> wrote:
>
> >+ clink = pnp_alloc(sizeof(*clink));
> >+ if (!clink)
> >+ return 0;
> >+ clink->card = card;
> >+ clink->driver = drv;
> >+ clink->pm_state = PMSG_ON;
>
> Memory leak of clink on next test.
>
> >+
> >+ if (drv->probe(clink, id) >= 0)
> >+ return 1;
> >+
> >+ /* Recovery */
> >+ card_for_each_dev(card, dev) {
> >+ if (dev->card_link == clink)
> >+ pnp_release_card_device(dev);
> > }
> >+ kfree(clink);
> > return 0;
> > }

No, if ->probe succeeded, it took over control of the memory at *clink.

It's all rather twisty and quite undocumented.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/