Re: [PATCH] platform/x86/amd/pmf: Fix memory leak in NPU metrics query

From: Ilpo Järvinen

Date: Thu Nov 19 2026 - 11:03:24 EST


On Fri, 23 Oct 2026 10:08:45 +0200, Awal Awal wrote:

> amd_pmf_get_smu_metrics() calls amd_pmf_set_dram_addr() with
> alloc_buffer set to true on every NPU metrics request. Each call
> devm_kzalloc()s a new metrics table buffer and overwrites dev->buf with
> it. The previous buffer stays on the devres list and is only released
> when the device is unbound, so every request leaks one buffer.
>
> amdxdna calls amd_pmf_get_npu_data() for its sensor query, so any
> userspace monitor that polls NPU utilisation through
> DRM_IOCTL_AMDXDNA_GET_INFO leaks memory for as long as it runs. On a
> Ryzen AI 9 365 (family 1Ah model 20h) laptop with a system monitor
> polling about 1.4 times per second, the kmalloc-512 cache grew to 5.8
> million objects (2.8 GiB) over 38 days of uptime.
>
> [...]

Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also
fixes are mostly routed through for-next unless the fix is for a
commit introduced in the most recent cycle or is clearly a regression
fix.

The list of commits applied:
[1/1] platform/x86/amd/pmf: Fix memory leak in NPU metrics query
commit: 3f1be6b854af29f030e3199d85e79d28cfe766a6

--
i.