mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/iccsense: Free temporary BIOS rail table
@ 2026-11-19  4:15 Haoxiang Li
  2026-12-04  1:24 ` Lyude Paul
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-11-19  4:15 UTC (permalink / raw)
  To: lyude, dakr, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona, haoxiang_li2024, martin.peres, nouveau
  Cc: dri-devel, nouveau, linux-kernel

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@163.com>
---
 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;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/nouveau/iccsense: Free temporary BIOS rail table
  2026-11-19  4:15 [PATCH] drm/nouveau/iccsense: Free temporary BIOS rail table Haoxiang Li
@ 2026-12-04  1:24 ` Lyude Paul
  0 siblings, 0 replies; 2+ messages in thread
From: Lyude Paul @ 2026-12-04  1:24 UTC (permalink / raw)
  To: Haoxiang Li, dakr, maarten.lankhorst, mripard, tzimmermann,
	airlied, simona, martin.peres, nouveau
  Cc: dri-devel, nouveau, linux-kernel

Reviewed-by: Lyude Paul <lyude.paul@maintainer.cc>

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@163.com>
> ---
>  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;
>  }
>  

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04  1:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19  4:15 [PATCH] drm/nouveau/iccsense: Free temporary BIOS rail table Haoxiang Li
2026-12-04  1:24 ` Lyude Paul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®