[PATCH 4.18 053/235] video: goldfishfb: fix memory leak on driver remove

From: Greg Kroah-Hartman
Date: Mon Sep 24 2018 - 08:29:46 EST


4.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Anton Vasilyev <vasilyev@xxxxxxxxx>

[ Upstream commit 5958fde72d04e7b8c6de3669d1f794a90997e3eb ]

goldfish_fb_probe() allocates memory for fb, but goldfish_fb_remove() does
not have deallocation of fb, which leads to memory leak on probe/remove.

The patch adds deallocation into goldfish_fb_remove().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@xxxxxxxxx>
Cc: Aleksandar Markovic <aleksandar.markovic@xxxxxxxx>
Cc: Miodrag Dinic <miodrag.dinic@xxxxxxxx>
Cc: Goran Ferenc <goran.ferenc@xxxxxxxx>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@xxxxxxxxxxx>
Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/video/fbdev/goldfishfb.c | 1 +
1 file changed, 1 insertion(+)

--- a/drivers/video/fbdev/goldfishfb.c
+++ b/drivers/video/fbdev/goldfishfb.c
@@ -301,6 +301,7 @@ static int goldfish_fb_remove(struct pla
dma_free_coherent(&pdev->dev, framesize, (void *)fb->fb.screen_base,
fb->fb.fix.smem_start);
iounmap(fb->reg_base);
+ kfree(fb);
return 0;
}