[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211217022129.470389-1-jiasheng@iscas.ac.cn>
Date: Fri, 17 Dec 2021 10:21:29 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: alexander.deucher@....com, christian.koenig@....com,
airlied@...ux.ie, daniel@...ll.ch, Hawking.Zhang@....com,
kevin1.wang@....com, Feifei.Xu@....com, Oak.Zeng@....com,
john.clements@....com, Jinzhou.Su@....com, Jiawei.Gu@....com,
Dennis.Li@....com
Cc: amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] drm/amdgpu: potential dereference of null pointer
The return value of dma_alloc_coherent() needs to be checked.
To avoid use of null pointer in memcpy_toio() in case of the failure of
alloc.
Fixes: 57430471e2fa ("drm/amdgpu: Add support for USBC PD FW download")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index a09483beb968..613e25bf87e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -3034,6 +3034,10 @@ static ssize_t psp_usbc_pd_fw_sysfs_write(struct device *dev,
/* We need contiguous physical mem to place the FW for psp to access */
cpu_addr = dma_alloc_coherent(adev->dev, usbc_pd_fw->size, &dma_addr, GFP_KERNEL);
+ if (!cpu_addr) {
+ ret = -ENOMEM;
+ goto rel_buf;
+ }
ret = dma_mapping_error(adev->dev, dma_addr);
if (ret)
--
2.25.1
Powered by blists - more mailing lists