Skip to content

Commit ddf75a8

Browse files
Jianglei Nieojeda
authored andcommitted
auxdisplay: hd44780: Fix potential memory leak in hd44780_remove()
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. Fixes: 718e05e ("auxdisplay: Introduce hd44780_common.[ch]") Reviewed-by: Andy Shevchenko <[email protected]> Reported-by: kernel test robot <[email protected]> Signed-off-by: Jianglei Nie <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 830b3c6 commit ddf75a8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/auxdisplay/hd44780.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,10 @@ static int hd44780_probe(struct platform_device *pdev)
322322
static int hd44780_remove(struct platform_device *pdev)
323323
{
324324
struct charlcd *lcd = platform_get_drvdata(pdev);
325+
struct hd44780_common *hdc = lcd->drvdata;
325326

326327
charlcd_unregister(lcd);
328+
kfree(hdc->hd44780);
327329
kfree(lcd->drvdata);
328330

329331
kfree(lcd);

0 commit comments

Comments
 (0)