Re: [PATCH v1 1/4] auxdisplay: hd44780: Fix memory leak on ->remove()

From: Geert Uytterhoeven
Date: Tue Mar 12 2019 - 11:04:42 EST


Hi Andy,

On Tue, Mar 12, 2019 at 3:40 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> On Tue, Mar 12, 2019 at 02:47:01PM +0100, Geert Uytterhoeven wrote:
> > On Tue, Mar 12, 2019 at 2:18 PM Andy Shevchenko
> > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > > We have to free on ->remove() the allocated resources on ->probe().
> > >
> > > Fixes: d47d88361fee ("auxdisplay: Add HD44780 Character LCD support")
> > > Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> >
> > Thanks, nice catch!
> >
> > (wearing a newer (and hopefully wiser ;-) hat than when I wrote the code)
> >
> > While this is correct for the current implementation of struct charlcd_priv,
> > this may be a bit fragile.
>
> This patch will be the same in the next version due to possibility to easy
> backport.

OK.

> > What about adding a charlcd_free() wrapper, which can do kfree(to_priv(lcd)),
> > and be used in the probe failure path, too?
>
> This has been partially done in the rest of the series, but I got your advise
> and will change to use to_priv() in v2. Thanks!

Ah, hadn't noticed the rest of the series. Will review...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds