* [PATCH V2] drm/amdgpu: check return value of xa_store()
@ 2025-07-31 2:08 Salah Triki
0 siblings, 0 replies; only message in thread
From: Salah Triki @ 2025-07-31 2:08 UTC (permalink / raw)
To: Markus Elfring, Alex Deucher, Christian König, David Airlie,
Simona Vetter, amd-gfx, dri-devel, linux-kernel, stable
Cc: salah.triki
The `xa_store()` function can fail due to memory allocation issues or other
internal errors. Currently, the return value of `xa_store()` is not
checked, which can lead to a memory leak if it fails to store `numa_info`.
This patch checks the return value of `xa_store()`. If an error is
detected, the allocated `numa_info` is freed, and NULL is returned to
indicate the failure, preventing a memory leak and ensuring proper error
handling.
Signed-off-by: Salah Triki <salah.triki@gmail.com>
Fixes: 1cc823011a23f ("drm/amdgpu: Store additional numa node information")
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
---
Changes in v2:
- Improve description
- Add tags Fixes and Cc
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index f5466c592d94..b4a3e4d3e957 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -876,7 +876,7 @@ static inline uint64_t amdgpu_acpi_get_numa_size(int nid)
static struct amdgpu_numa_info *amdgpu_acpi_get_numa_info(uint32_t pxm)
{
- struct amdgpu_numa_info *numa_info;
+ struct amdgpu_numa_info *numa_info, *old;
int nid;
numa_info = xa_load(&numa_info_xa, pxm);
@@ -898,7 +898,11 @@ static struct amdgpu_numa_info *amdgpu_acpi_get_numa_info(uint32_t pxm)
} else {
numa_info->size = amdgpu_acpi_get_numa_size(nid);
}
- xa_store(&numa_info_xa, numa_info->pxm, numa_info, GFP_KERNEL);
+ old = xa_store(&numa_info_xa, numa_info->pxm, numa_info, GFP_KERNEL);
+ if (xa_is_err(old)) {
+ kfree(numa_info);
+ return NULL;
+ }
}
return numa_info;
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-07-31 2:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-31 2:08 [PATCH V2] drm/amdgpu: check return value of xa_store() Salah Triki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).