Skip to contentSkip to conversation

drm/amdgpu: Fix the null pointer when load rlc firmware

PATCH In review Ma Jun 2 participants 2 messages Jan 12, 2024

Subsystems (2)
lore
Share & tools
lore

Ma Jun

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix the null pointer when load rlc firmware

If the RLC firmware is invalid because of wrong header size, the pointer to the rlc firmware is released in function amdgpu_ucode_request. There will be a null pointer error in subsequent use. So skip validation to fix it.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +6 -9
index d2c34436aefc..4d90e570b3cd 100644
@@ -3996,16 +3996,13 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)
 
 	if (!amdgpu_sriov_vf(adev)) {
 		snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);
-		err = amdgpu_ucode_request(adev, &adev->gfx.rlc_fw, fw_name);
-		/* don't check this.  There are apparently firmwares in the wild with
-		 * incorrect size in the header
-		 */
-		if (err == -ENODEV)
-			goto out;
+		err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev);
 		if (err)
-			dev_dbg(adev->dev,
-				"gfx10: amdgpu_ucode_request() failed \"%s\"\n",
-				fw_name);
+			goto out;
+
+		/* don't validate this firmware.  There are apparently firmwares
+		 * in the wild with incorrect size in the header
+		 */
 		rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;
 		version_major = le16_to_cpu(rlc_hdr->header.header_version_major);
 		version_minor = le16_to_cpu(rlc_hdr->header.header_version_minor);
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw

[Public]

________________________________
From: Ma, Jun <[email protected]>
Sent: Friday, January 12, 2024 1:26 AM
To: [email protected] <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>
Cc: Ma, Jun <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix the null pointer when load rlc firmware

If the RLC firmware is invalid because of wrong header size, the pointer to the rlc firmware is released in function amdgpu_ucode_request. There will be a null pointer error in subsequent use. So skip validation to fix it.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +6 -9
index d2c34436aefc..4d90e570b3cd 100644
@@ -3996,16 +3996,13 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)
 
         if (!amdgpu_sriov_vf(adev)) {
                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);
-               err = amdgpu_ucode_request(adev, &adev->gfx.rlc_fw, fw_name);
-               /* don't check this.  There are apparently firmwares in the wild with
-                * incorrect size in the header
-                */
-               if (err == -ENODEV)
-                       goto out;
+               err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev);
                 if (err)
-                       dev_dbg(adev->dev,
-                               "gfx10: amdgpu_ucode_request() failed \"%s\"\n",
-                               fw_name);
+                       goto out;
+
+               /* don't validate this firmware.  There are apparently firmwares
+                * in the wild with incorrect size in the header
+                */
                 rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;
                 version_major = le16_to_cpu(rlc_hdr->header.header_version_major);
                 version_minor = le16_to_cpu(rlc_hdr->header.header_version_minor);

--
2.34.1