Commit 52671c08 authored by Zhen Lei's avatar Zhen Lei Committed by Liu Shixin
Browse files

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

stable inclusion
from stable-v4.19.325
commit 0d3fb3b3e9d66f7b6346e3b90bc0ff48683539ce
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBEGG7
CVE: CVE-2024-56746

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0d3fb3b3e9d66f7b6346e3b90bc0ff48683539ce



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

[ Upstream commit f89d17ae2ac42931be2a0153fecbf8533280c927 ]

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: 4a25e418 ("video: sh7760fb: SH7760/SH7763 LCDC framebuffer driver")
Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent 6be283e3
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -412,12 +412,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;