[PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c

Haoxiang Li posted 1 patch 11 months, 2 weeks ago
drivers/auxdisplay/hd44780.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c
Posted by Haoxiang Li 11 months, 2 weeks ago
Variable allocated by charlcd_alloc() should be released
by charlcd_free(). The following patch changed kfree() to
charlcd_free() to fix an API misuse.

Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
Changes in v2:
- Merge the two patches into one.
- Modify the patch description.
Sorry Geert, I didn't see your reply until after I sent the
second patch. I've merged the two patches into one, hoping
to make your work a bit easier! Thanks a lot!
---
 drivers/auxdisplay/hd44780.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c
index 0526f0d90a79..9d0ae9c02e9b 100644
--- a/drivers/auxdisplay/hd44780.c
+++ b/drivers/auxdisplay/hd44780.c
@@ -313,7 +313,7 @@ static int hd44780_probe(struct platform_device *pdev)
 fail3:
 	kfree(hd);
 fail2:
-	kfree(lcd);
+	charlcd_free(lcd);
 fail1:
 	kfree(hdc);
 	return ret;
@@ -328,7 +328,7 @@ static void hd44780_remove(struct platform_device *pdev)
 	kfree(hdc->hd44780);
 	kfree(lcd->drvdata);
 
-	kfree(lcd);
+	charlcd_free(lcd);
 }
 
 static const struct of_device_id hd44780_of_match[] = {
-- 
2.25.1
Re: [PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c
Posted by Andy Shevchenko 11 months, 2 weeks ago
On Mon, Feb 24, 2025 at 06:15:27PM +0800, Haoxiang Li wrote:
> Variable allocated by charlcd_alloc() should be released
> by charlcd_free(). The following patch changed kfree() to
> charlcd_free() to fix an API misuse.

> Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]")
> Cc: stable@vger.kernel.org

Okay, looking closer to the current state of affairs, the change
does not fix anything actually. OTOH it's correct semantically and
allows to do any further development in charlcd_alloc(), if any.

That said, if Geert is okay with it, I would like to apply but without
Fixes/Cc: stable@ tags.

P.S.
The very similar needs to be applied to panel.c, but I already have
a patch for that locally, thanks to this thread.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c
Posted by Geert Uytterhoeven 11 months, 2 weeks ago
Hi Andy,

On Mon, 24 Feb 2025 at 13:35, Andy Shevchenko <andy@kernel.org> wrote:
> On Mon, Feb 24, 2025 at 06:15:27PM +0800, Haoxiang Li wrote:
> > Variable allocated by charlcd_alloc() should be released
> > by charlcd_free(). The following patch changed kfree() to
> > charlcd_free() to fix an API misuse.
>
> > Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]")
> > Cc: stable@vger.kernel.org
>
> Okay, looking closer to the current state of affairs, the change
> does not fix anything actually. OTOH it's correct semantically and
> allows to do any further development in charlcd_alloc(), if any.
>
> That said, if Geert is okay with it, I would like to apply but without
> Fixes/Cc: stable@ tags.

I had mixed feelings about the Fixes-tag, too.
Semantically, it's indeed a fix.  If any further cleanups are ever done
and backported, but this patch would be  missed, it would introduce a bug.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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
Re: [PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c
Posted by Andy Shevchenko 11 months, 2 weeks ago
On Mon, Feb 24, 2025 at 02:33:49PM +0100, Geert Uytterhoeven wrote:
> On Mon, 24 Feb 2025 at 13:35, Andy Shevchenko <andy@kernel.org> wrote:
> > On Mon, Feb 24, 2025 at 06:15:27PM +0800, Haoxiang Li wrote:
> > > Variable allocated by charlcd_alloc() should be released
> > > by charlcd_free(). The following patch changed kfree() to
> > > charlcd_free() to fix an API misuse.
> >
> > > Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]")
> > > Cc: stable@vger.kernel.org
> >
> > Okay, looking closer to the current state of affairs, the change
> > does not fix anything actually. OTOH it's correct semantically and
> > allows to do any further development in charlcd_alloc(), if any.
> >
> > That said, if Geert is okay with it, I would like to apply but without
> > Fixes/Cc: stable@ tags.
> 
> I had mixed feelings about the Fixes-tag, too.
> Semantically, it's indeed a fix.  If any further cleanups are ever done
> and backported, but this patch would be  missed, it would introduce a bug.

Okay, I return it.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c
Posted by Geert Uytterhoeven 11 months, 2 weeks ago
On Mon, 24 Feb 2025 at 11:16, Haoxiang Li <haoxiang_li2024@163.com> wrote:
> Variable allocated by charlcd_alloc() should be released
> by charlcd_free(). The following patch changed kfree() to
> charlcd_free() to fix an API misuse.
>
> Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
> Changes in v2:
> - Merge the two patches into one.
> - Modify the patch description.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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
Re: [PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c
Posted by Andy Shevchenko 11 months, 2 weeks ago
On Mon, Feb 24, 2025 at 01:30:47PM +0100, Geert Uytterhoeven wrote:
> On Mon, 24 Feb 2025 at 11:16, Haoxiang Li <haoxiang_li2024@163.com> wrote:
> > Variable allocated by charlcd_alloc() should be released
> > by charlcd_free(). The following patch changed kfree() to
> > charlcd_free() to fix an API misuse.
> >
> > Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> > ---
> > Changes in v2:
> > - Merge the two patches into one.
> > - Modify the patch description.
> 
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Pushed to my review and testing queue, thanks!

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c
Posted by Andy Shevchenko 11 months, 2 weeks ago
On Mon, Feb 24, 2025 at 06:15:27PM +0800, Haoxiang Li wrote:
> Variable allocated by charlcd_alloc() should be released
> by charlcd_free(). The following patch changed kfree() to
> charlcd_free() to fix an API misuse.

> ---
> Changes in v2:
> - Merge the two patches into one.
> - Modify the patch description.
> Sorry Geert, I didn't see your reply until after I sent the
> second patch. I've merged the two patches into one, hoping
> to make your work a bit easier! Thanks a lot!

Btw, have you seen this one?

https://lore.kernel.org/r/20221128084421.8626-1-niejianglei2021@163.com

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2] auxdisplay: hd44780: Fix an API misuse in hd44780.c
Posted by Andy Shevchenko 11 months, 2 weeks ago
On Mon, Feb 24, 2025 at 06:15:27PM +0800, Haoxiang Li wrote:
> Variable allocated by charlcd_alloc() should be released
> by charlcd_free(). The following patch changed kfree() to
> charlcd_free() to fix an API misuse.

...

> - Merge the two patches into one.

Thanks!

> - Modify the patch description.
> Sorry Geert, I didn't see your reply until after I sent the
> second patch. I've merged the two patches into one, hoping
> to make your work a bit easier! Thanks a lot!

In any case it's better if Geert acks/reviews this one as from code p.o.v.
it's a 50% change :-)

-- 
With Best Regards,
Andy Shevchenko