From: Kent Russell Date: Mon, 2 Nov 2020 16:17:59 +0000 (-0500) Subject: amdkfd: Check kvmalloc return before memcpy X-Git-Tag: baikal/mips/sdk5.9~12066^2~12^2~34 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=66a0b9f5d6bcf7feb6517834a70a2c3b46176aaf;p=kernel.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 cdd5032d5c0e6..a0acf23103575 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;