Skip to contentSkip to conversation

drm/amd: Fix an error handling mistake in psp_sw_init()

PATCH In review Mario Limonciello 2 participants 3 messages Jul 13, 2023 – Jul 19, 2023

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

PATCH 1/1 drm/amd: Fix an error handling mistake in psp_sw_init()

If the second call to amdgpu_bo_create_kernel() fails, the memory allocated from the first call should be cleared. If the third call fails, the memory from the second call should be cleared.

Fixes b95b5391684b ("drm/amdgpu/psp: move PSP memory alloc from hw_init to sw_init")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -3
index 1b4d5f04d968..6ffc1a640d2d 100644
@@ -491,11 +491,11 @@ static int psp_sw_init(void *handle)
 	return 0;
 
 failed2:
-	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
-			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
-failed1:
 	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
 			      &psp->fence_buf_mc_addr, &psp->fence_buf);
+failed1:
+	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
+			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
 	return ret;
 }
 
Signature · 1 line
2.34.1
#1 lore raw

[Public]

Quoted 7 lines

-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Thursday, July 13, 2023 00:15
To: [email protected]
Cc: Limonciello, Mario <[email protected]>
Subject: [PATCH] drm/amd: Fix an error handling mistake in psp_sw_init()

Quoted 7 lines

If the second call to amdgpu_bo_create_kernel() fails, the memory allocated from the first call should be cleared. If the third call fails, the memory from the second call should be cleared.

Fixes b95b5391684b ("drm/amdgpu/psp: move PSP memory alloc from

hw_init to sw_init")

Ping on this one.

Quoted 26 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -4
index 1b4d5f04d968..6ffc1a640d2d 100644
@@ -491,11 +491,11 @@ static int psp_sw_init(void *handle)
      return 0;
 
 failed2:
-     amdgpu_bo_free_kernel(&psp->fw_pri_bo,
-                           &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
-failed1:
      amdgpu_bo_free_kernel(&psp->fence_buf_bo,
                            &psp->fence_buf_mc_addr, &psp->fence_buf);
+failed1:
+     amdgpu_bo_free_kernel(&psp->fw_pri_bo,
+                           &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
      return ret;
 }
 
--

2.34.1

Reviewed-by
#2 lore raw
Quoted 15 lines · Mario

[Public]

[Public]

Quoted 11 lines

-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Thursday, July 13, 2023 00:15
To: [email protected]
Cc: Limonciello, Mario <[email protected]>
Subject: [PATCH] drm/amd: Fix an error handling mistake in psp_sw_init()

If the second call to amdgpu_bo_create_kernel() fails, the memory allocated from the first call should be cleared. If the third call fails, the memory from the second call should be cleared.

Quoted 6 lines
Quoted 3 lines
Fixes b95b5391684b ("drm/amdgpu/psp: move PSP memory alloc from

hw_init to sw_init")

Ping on this one.

Thanks,
Lijo

Quoted 27 lines
Quoted 26 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -4
index 1b4d5f04d968..6ffc1a640d2d 100644
@@ -491,11 +491,11 @@ static int psp_sw_init(void *handle)
       return 0;
 
  failed2:
-     amdgpu_bo_free_kernel(&psp->fw_pri_bo,
-                           &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
-failed1:
       amdgpu_bo_free_kernel(&psp->fence_buf_bo,
                             &psp->fence_buf_mc_addr, &psp->fence_buf);
+failed1:
+     amdgpu_bo_free_kernel(&psp->fw_pri_bo,
+                           &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
       return ret;
  }
 
--

2.34.1