linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jianglei Nie <niejianglei2021@163.com>
To: ojeda@kernel.org
Cc: linux-kernel@vger.kernel.org, Jianglei Nie <niejianglei2021@163.com>
Subject: [PATCH] auxdisplay: hd44780: Fix potential memory leak in hd44780_remove()
Date: Mon,  4 Jul 2022 09:27:09 +0800	[thread overview]
Message-ID: <20220704012709.2217923-1-niejianglei2021@163.com> (raw)

hd44780_probe() allocates a memory chunk for hd with kzalloc() and
makes "lcd->drvdata->hd44780" point to it. When we call hd44780_remove(),
we should release all relevant memory and resource, but "lcd->drvdata
->hd44780" is not released, which will lead to a memory leak.

We should release the "lcd->drvdata->hd44780" in hd44780_remove() to fix
the memory leak bug.

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
 drivers/auxdisplay/hd44780.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c
index 8b2a0eb3f32a..8940a93d2d4d 100644
--- a/drivers/auxdisplay/hd44780.c
+++ b/drivers/auxdisplay/hd44780.c
@@ -324,6 +324,7 @@ static int hd44780_remove(struct platform_device *pdev)
 	struct charlcd *lcd = platform_get_drvdata(pdev);
 
 	charlcd_unregister(lcd);
+	kfree(lcd->drvdata->hd44780);
 	kfree(lcd->drvdata);
 
 	kfree(lcd);
-- 
2.25.1


             reply	other threads:[~2022-07-04  1:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04  1:27 Jianglei Nie [this message]
2022-09-07  7:07 [PATCH] auxdisplay: hd44780: Fix potential memory leak in hd44780_remove() Jianglei Nie
2022-09-07  9:36 ` kernel test robot
2022-09-07  9:56 ` kernel test robot
2022-09-07 10:17 ` kernel test robot
2022-11-24 19:19 ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220704012709.2217923-1-niejianglei2021@163.com \
    --to=niejianglei2021@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).