fbdev: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()
[ 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: 4a25e41831 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3b69263ada
commit
0d3fb3b3e9
@@ -412,12 +412,11 @@ static int sh7760fb_alloc_mem(struct fb_info *info)
|
|||||||
vram = PAGE_SIZE;
|
vram = PAGE_SIZE;
|
||||||
|
|
||||||
fbmem = dma_alloc_coherent(info->device, vram, &par->fbdma, GFP_KERNEL);
|
fbmem = dma_alloc_coherent(info->device, vram, &par->fbdma, GFP_KERNEL);
|
||||||
|
|
||||||
if (!fbmem)
|
if (!fbmem)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if ((par->fbdma & SH7760FB_DMA_MASK) != SH7760FB_DMA_MASK) {
|
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"
|
dev_err(info->device, "kernel gave me memory at 0x%08lx, which is"
|
||||||
"unusable for the LCDC\n", (unsigned long)par->fbdma);
|
"unusable for the LCDC\n", (unsigned long)par->fbdma);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|||||||
Reference in New Issue
Block a user