Re: [PATCH v3] drm/amdgpu: Fix the memory allocation issue in amdgpu_discovery_get_nps_info()

From: Markus Elfring
Date: Tue Oct 29 2024 - 15:49:42 EST



> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> @@ -1757,11 +1757,13 @@ int amdgpu_discovery_get_nps_info(struct amdgpu_device *adev,
>
> switch (le16_to_cpu(nps_info->v1.header.version_major)) {
> case 1:
> + mem_ranges = kvcalloc(nps_info->v1.count,
> + sizeof(struct amdgpu_gmc_memrange),
> + GFP_KERNEL);


Can the specification “sizeof(*mem_ranges)” be more appropriate here?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.12-rc5#n941

Regards,
Markus