[PATCH] video: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()

Subsystems: framebuffer layer, the rest

STALE655d

3 messages, 3 authors, 2024-11-14 · open the first message on its own page

[PATCH] video: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()

From: Zhen Lei <hidden>
Date: 2024-10-26 04:16:35

When information such as info->screen_base is not ready, calling
sh7760fb_free_mem() does not release memory correctly. Call
dma_free_coherent() instead.

Fixes: 4a25e41831ee ("video: sh7760fb: SH7760/SH7763 LCDC framebuffer driver")
Signed-off-by: Zhen Lei <redacted>
---
 drivers/video/fbdev/sh7760fb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/video/fbdev/sh7760fb.c b/drivers/video/fbdev/sh7760fb.c
index 3d2a27fefc874a7..130adef2e468697 100644
--- a/drivers/video/fbdev/sh7760fb.c
+++ b/drivers/video/fbdev/sh7760fb.c
@@ -409,12 +409,11 @@ static int sh7760fb_alloc_mem(struct fb_info *info)
 		vram = PAGE_SIZE;
 
 	fbmem = dma_alloc_coherent(info->device, vram, &par->fbdma, GFP_KERNEL);
-
 	if (!fbmem)
 		return -ENOMEM;
 
 	if ((par->fbdma & SH7760FB_DMA_MASK) != SH7760FB_DMA_MASK) {
-		sh7760fb_free_mem(info);
+		dma_free_coherent(info->device, vram, fbmem, par->fbdma);
 		dev_err(info->device, "kernel gave me memory at 0x%08lx, which is"
 			"unusable for the LCDC\n", (unsigned long)par->fbdma);
 		return -ENOMEM;
-- 
2.34.1

Re: [PATCH] video: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()

From: Dmitry Baryshkov <hidden>
Date: 2024-10-28 10:41:23

On Sat, Oct 26, 2024 at 11:56:34AM +0800, Zhen Lei wrote:
When information such as info->screen_base is not ready, calling
sh7760fb_free_mem() does not release memory correctly. Call
dma_free_coherent() instead.

Fixes: 4a25e41831ee ("video: sh7760fb: SH7760/SH7763 LCDC framebuffer driver")
Signed-off-by: Zhen Lei <redacted>
---
 drivers/video/fbdev/sh7760fb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Dmitry Baryshkov <redacted>

-- 
With best wishes
Dmitry

Re: [PATCH] video: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()

From: Helge Deller <deller@gmx.de>
Date: 2024-11-14 14:28:47

On 10/28/24 11:41, Dmitry Baryshkov wrote:
On Sat, Oct 26, 2024 at 11:56:34AM +0800, Zhen Lei wrote:
quoted
When information such as info->screen_base is not ready, calling
sh7760fb_free_mem() does not release memory correctly. Call
dma_free_coherent() instead.

Fixes: 4a25e41831ee ("video: sh7760fb: SH7760/SH7763 LCDC framebuffer driver")
Signed-off-by: Zhen Lei <redacted>
---
  drivers/video/fbdev/sh7760fb.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
Reviewed-by: Dmitry Baryshkov <redacted>
applied to fbdev git tree.

Thanks!
Helge
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help