<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:11pt;color:#0078D7;margin:5pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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 Kent Russell <kent.russell@amd.com><br>
<b>Sent:</b> Monday, November 2, 2020 11:27 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Russell, Kent <Kent.Russell@amd.com><br>
<b>Subject:</b> [PATCH] amdkfd: Check kvmalloc return before memcpy</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">If we can't kvmalloc the pcrat_image, then we shouldn't memcpy<br>
<br>
Signed-off-by: Kent Russell <kent.russell@amd.com><br>
Reported-by: kernel test robot <lkp@intel.com><br>
---<br>
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-<br>
 1 file changed, 1 insertion(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c<br>
index cdd5032d5c0e..a0acf2310357 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c<br>
@@ -804,10 +804,10 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)<br>
         }<br>
 <br>
         pcrat_image = kvmalloc(crat_table->length, GFP_KERNEL);<br>
-       memcpy(pcrat_image, crat_table, crat_table->length);<br>
         if (!pcrat_image)<br>
                 return -ENOMEM;<br>
 <br>
+       memcpy(pcrat_image, crat_table, crat_table->length);<br>
         *crat_image = pcrat_image;<br>
         *size = crat_table->length;<br>
 <br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Calexander.deucher%40amd.com%7C20c8797c2a6d4fb8bf5a08d87f4c3732%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637399312636837144%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=84VCnd9ugeRKlAyqOYpXHm2PvPXUhM0gQjJd9AR95mA%3D&amp;reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Calexander.deucher%40amd.com%7C20c8797c2a6d4fb8bf5a08d87f4c3732%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637399312636837144%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=84VCnd9ugeRKlAyqOYpXHm2PvPXUhM0gQjJd9AR95mA%3D&amp;reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>