Re: [PATCH] drm/nouveau/iccsense: Free temporary BIOS rail table
From: Lyude Paul
Date: Thu Dec 03 2026 - 20:24:41 EST
Reviewed-by: Lyude Paul <lyude.paul@xxxxxxxxxxxxx>
Will push to drm-misc-next in a moment
On Thu, 2026-11-19 at 12:15 +0800, Haoxiang Li wrote:
> nvbios_iccsense_parse() allocates stbl.rail, but never releases it,
> leaking the allocation both on successful initialization and when
> allocating a runtime rail fails.
>
> The sensor and runtime rail objects store copies of the parsed
> fields, so the temporary table is not owned or freed by the
> subdevice destructor.
>
> Free stbl.rail after processing the entries and before returning
> on runtime rail allocation failure.
>
> Fixes: b71c0892631a ("drm/nouveau/iccsense: implement for ina209,
> ina219 and ina3221")
> Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx>
> ---
> drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index 3ccdbbe2fad0..85fd891442e4 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev
> *subdev)
> }
>
> rail = kmalloc_obj(*rail);
> - if (!rail)
> + if (!rail) {
> + kfree(stbl.rail);
> return -ENOMEM;
> + }
>
> rail->read = read;
> rail->sensor = sensor;
> @@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> list_add_tail(&rail->head, &iccsense-
> >rails);
> }
> }
> + kfree(stbl.rail);
> return 0;
> }
>