[PATCH] drm/amdgpu: potential dereference of null pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux