From: Kent Russell Date: Mon, 2 Nov 2020 16:17:59 +0000 (-0500) Subject: amdkfd: Check kvmalloc return before memcpy X-Git-Tag: howlett/maple_spf/20210104~614^2~1^2~11 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2e3a57f4905b4fa6d9b66e9a675c288093c93bf0;p=users%2Fjedix%2Flinux-maple.git amdkfd: Check kvmalloc return before memcpy If we can't kvmalloc the pcrat_image, then we shouldn't memcpy Signed-off-by: Kent Russell Reported-by: kernel test robot Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c index 5e2254b9e931..3de5e14c5ae3 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -798,10 +798,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;