Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()

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 <thunder.leizhen@huawei.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Zhen Lei and committed by
Helge Deller
f89d17ae 2d5404ca

+1 -2
+1 -2
drivers/video/fbdev/sh7760fb.c
··· 409 409 vram = PAGE_SIZE; 410 410 411 411 fbmem = dma_alloc_coherent(info->device, vram, &par->fbdma, GFP_KERNEL); 412 - 413 412 if (!fbmem) 414 413 return -ENOMEM; 415 414 416 415 if ((par->fbdma & SH7760FB_DMA_MASK) != SH7760FB_DMA_MASK) { 417 - sh7760fb_free_mem(info); 416 + dma_free_coherent(info->device, vram, fbmem, par->fbdma); 418 417 dev_err(info->device, "kernel gave me memory at 0x%08lx, which is" 419 418 "unusable for the LCDC\n", (unsigned long)par->fbdma); 420 419 return -ENOMEM;