<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:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<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">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</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> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of David Francis <David.Francis@amd.com><br>
<b>Sent:</b> Monday, September 11, 2023 9:44 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Francis, David <David.Francis@amd.com><br>
<b>Subject:</b> [PATCH v2] drm/amdgpu: Handle null atom context in VBIOS info ioctl</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On some APU systems, there is no atom context and so the<br>
atom_context struct is null.<br>
<br>
Add a check to the VBIOS_INFO branch of amdgpu_info_ioctl<br>
to handle this case, returning all zeroes.<br>
<br>
v2: Maintain current use of {} initialization.<br>
<br>
Signed-off-by: David Francis <David.Francis@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 17 +++++++++++------<br>
1 file changed, 11 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
index d462b36adf4b..a74ea53899f6 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
@@ -951,12 +951,17 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)<br>
struct atom_context *atom_context;<br>
<br>
atom_context = adev->mode_info.atom_context;<br>
- memcpy(vbios_info.name, atom_context->name, sizeof(atom_context->name));<br>
- memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, sizeof(atom_context->vbios_pn));<br>
- vbios_info.version = atom_context->version;<br>
- memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,<br>
- sizeof(atom_context->vbios_ver_str));<br>
- memcpy(vbios_info.date, atom_context->date, sizeof(atom_context->date));<br>
+ if (atom_context) {<br>
+ memcpy(vbios_info.name, atom_context->name,<br>
+ sizeof(atom_context->name));<br>
+ memcpy(vbios_info.vbios_pn, atom_context->vbios_pn,<br>
+ sizeof(atom_context->vbios_pn));<br>
+ vbios_info.version = atom_context->version;<br>
+ memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,<br>
+ sizeof(atom_context->vbios_ver_str));<br>
+ memcpy(vbios_info.date, atom_context->date,<br>
+ sizeof(atom_context->date));<br>
+ }<br>
<br>
return copy_to_user(out, &vbios_info,<br>
min((size_t)size, sizeof(vbios_info))) ? -EFAULT : 0;<br>
-- <br>
2.34.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>