Commit 6be283e3 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Liu Shixin
Browse files

fbdev/sh7760fb: Alloc DMA memory from hardware device

stable inclusion
from stable-v4.19.325
commit 3b69263adaaaa5513db98c5b3fe9053a21ff2a6d
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=3b69263adaaaa5513db98c5b3fe9053a21ff2a6d



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

[ Upstream commit 8404e56f ]

Pass the hardware device to the DMA helpers dma_alloc_coherent() and
dma_free_coherent(). The fbdev device that is currently being used is
a software device and does not provide DMA memory. Also update the
related dev_*() output statements similarly.

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230613110953.24176-28-tzimmermann@suse.de


Stable-dep-of: f89d17ae2ac4 ("fbdev: sh7760fb: Fix a possible memory leak in sh7760fb_alloc_mem()")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent bedee5b4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -362,7 +362,7 @@ static void sh7760fb_free_mem(struct fb_info *info)
	if (!info->screen_base)
		return;

	dma_free_coherent(info->dev, info->screen_size,
	dma_free_coherent(info->device, info->screen_size,
			  info->screen_base, par->fbdma);

	par->fbdma = 0;
@@ -411,14 +411,14 @@ static int sh7760fb_alloc_mem(struct fb_info *info)
	if (vram < PAGE_SIZE)
		vram = PAGE_SIZE;

	fbmem = dma_alloc_coherent(info->dev, vram, &par->fbdma, GFP_KERNEL);
	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);
		dev_err(info->dev, "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);
		return -ENOMEM;
	}
@@ -489,7 +489,7 @@ static int sh7760fb_probe(struct platform_device *pdev)

	ret = sh7760fb_alloc_mem(info);
	if (ret) {
		dev_dbg(info->dev, "framebuffer memory allocation failed!\n");
		dev_dbg(info->device, "framebuffer memory allocation failed!\n");
		goto out_unmap;
	}