lkml.org 
[lkml]   [2022]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] auxdisplay: hd44780: Fix potential memory leak in hd44780_remove()
Date
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
\
 
 \ /
  Last update: 2022-07-04 03:28    [W:0.027 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site