<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#008000;margin:15pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[Public]<br>
</p>
<br>
<div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Acked-by: Alex Deucher <alexander.deucher@amd.com></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Ma, Jun <Jun.Ma2@amd.com><br>
<b>Sent:</b> Friday, January 12, 2024 1:26 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Koenig, Christian <Christian.Koenig@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com><br>
<b>Cc:</b> Ma, Jun <Jun.Ma2@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: Fix the null pointer when load rlc firmware</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">If the RLC firmware is invalid because of wrong header size,<br>
the pointer to the rlc firmware is released in function<br>
amdgpu_ucode_request. There will be a null pointer error<br>
in subsequent use. So skip validation to fix it.<br>
<br>
Signed-off-by: Ma Jun <Jun.Ma2@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 15 ++++++---------<br>
 1 file changed, 6 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
index d2c34436aefc..4d90e570b3cd 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c<br>
@@ -3996,16 +3996,13 @@ static int gfx_v10_0_init_microcode(struct amdgpu_device *adev)<br>
 <br>
         if (!amdgpu_sriov_vf(adev)) {<br>
                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);<br>
-               err = amdgpu_ucode_request(adev, &adev->gfx.rlc_fw, fw_name);<br>
-               /* don't check this.  There are apparently firmwares in the wild with<br>
-                * incorrect size in the header<br>
-                */<br>
-               if (err == -ENODEV)<br>
-                       goto out;<br>
+               err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev);<br>
                 if (err)<br>
-                       dev_dbg(adev->dev,<br>
-                               "gfx10: amdgpu_ucode_request() failed \"%s\"\n",<br>
-                               fw_name);<br>
+                       goto out;<br>
+<br>
+               /* don't validate this firmware.  There are apparently firmwares<br>
+                * in the wild with incorrect size in the header<br>
+                */<br>
                 rlc_hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;<br>
                 version_major = le16_to_cpu(rlc_hdr->header.header_version_major);<br>
                 version_minor = le16_to_cpu(rlc_hdr->header.header_version_minor);<br>
-- <br>
2.34.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>