Re: [PATCH] amdkfd: Check kvmalloc return before memcpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only - Internal Distribution Only]


Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx>

From: amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> on behalf of Kent Russell <kent.russell@xxxxxxx>
Sent: Monday, November 2, 2020 11:27 AM
To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx <amd-gfx@xxxxxxxxxxxxxxxxxxxxx>
Cc: Russell, Kent <Kent.Russell@xxxxxxx>
Subject: [PATCH] amdkfd: Check kvmalloc return before memcpy
 
If we can't kvmalloc the pcrat_image, then we shouldn't memcpy

Signed-off-by: Kent Russell <kent.russell@xxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
index cdd5032d5c0e..a0acf2310357 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -804,10 +804,10 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)
         }
 
         pcrat_image = kvmalloc(crat_table->length, GFP_KERNEL);
-       memcpy(pcrat_image, crat_table, crat_table->length);
         if (!pcrat_image)
                 return -ENOMEM;
 
+       memcpy(pcrat_image, crat_table, crat_table->length);
         *crat_image = pcrat_image;
         *size = crat_table->length;
 
--
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://nam11.safelinks.protection.outlook.com/?url="">
_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux