Skip to contentSkip to conversation

drm/amd/amdgpu: Fix missing error return on kzalloc failure

PATCH Applied Colin Ian King 2 participants 2 messages Sep 2, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: Fix missing error return on kzalloc failure

Currently the kzalloc failure check just sets reports the failure and sets the variable ret to -ENOMEM, which is not checked later for this specific error. Fix this by just returning -ENOMEM rather than setting ret.

Fixes 4fb930715468 ("drm/amd/amdgpu: remove redundant host to psp cmd buf allocations")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
index 1d6e1d5de8fa..3696f48c233b 100644
@@ -448,7 +448,7 @@ static int psp_sw_init(struct amdgpu_ip_block *ip_block)
 	psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 	if (!psp->cmd) {
 		dev_err(adev->dev, "Failed to allocate memory to command buffer!\n");
-		ret = -ENOMEM;
+		return -ENOMEM;
 	}
 
 	adev->psp.xgmi_context.supports_extended_data =
Signature · 1 line
2.51.0
Applied
#1 lore raw

Applied. Thanks!

Alex

Quoted 28 lines · Colin Ian King

Currently the kzalloc failure check just sets reports the failure and sets the variable ret to -ENOMEM, which is not checked later for this specific error. Fix this by just returning -ENOMEM rather than setting ret.

Fixes 4fb930715468 ("drm/amd/amdgpu: remove redundant host to psp cmd buf allocations")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -2
index 1d6e1d5de8fa..3696f48c233b 100644
@@ -448,7 +448,7 @@ static int psp_sw_init(struct amdgpu_ip_block *ip_block)
        psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
        if (!psp->cmd) {
                dev_err(adev->dev, "Failed to allocate memory to command buffer!\n");
-               ret = -ENOMEM;
+               return -ENOMEM;
        }
 
        adev->psp.xgmi_context.supports_extended_data =
--

2.51.0