* [PATCH] drm/nouveau: Fix memory leak in nvbios_iccsense_parse
@ 2024-12-10 6:20 zhanxin
0 siblings, 0 replies; 3+ messages in thread
From: zhanxin @ 2024-12-10 6:20 UTC (permalink / raw)
To: kherbst, lyude, dakr, airlied, simona; +Cc: dri-devel, nouveau, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #1.2: Type: text/html, Size: 0 bytes --]
[-- Attachment #2: 0001-drm-nouveau-Fix-memory-leak-in-nvbios_iccsense_parse.patch --]
[-- Type: application/octet-stream, Size: 1016 bytes --]
From 895d436242c94c56a1d696c713016cc1504b9b83 Mon Sep 17 00:00:00 2001
From: Zhanxin Qi <zhanxin0@outlook.com>
Date: Tue, 10 Dec 2024 13:12:04 +0800
Subject: [PATCH] drm/nouveau: Fix memory leak in nvbios_iccsense_parse
The nvbios_iccsense_parse function allocates memory for sensor data
but fails to free it when the function exits, leading to a memory
leak. Add proper cleanup to free the allocated memory.
Signed-off-by: Zhanxin Qi <zhanxin0@outlook.com>
---
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index 8f0ccd3664eb..502608d575f7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -291,6 +291,9 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
list_add_tail(&rail->head, &iccsense->rails);
}
}
+
+ kfree(stbl.rail);
+
return 0;
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] drm/nouveau: Fix memory leak in nvbios_iccsense_parse
@ 2024-12-16 1:52 Zhanxin Qi
2024-12-16 9:45 ` Danilo Krummrich
0 siblings, 1 reply; 3+ messages in thread
From: Zhanxin Qi @ 2024-12-16 1:52 UTC (permalink / raw)
To: kherbst, lyude, dakr, airlied, simona
Cc: dri-devel, nouveau, linux-kernel, Zhanxin Qi
The nvbios_iccsense_parse function allocates memory for sensor data
but fails to free it when the function exits, leading to a memory
leak. Add proper cleanup to free the allocated memory.
Signed-off-by: Zhanxin Qi <zhanxin@nfschina.com>
---
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index 8f0ccd3664eb..502608d575f7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -291,6 +291,9 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
list_add_tail(&rail->head, &iccsense->rails);
}
}
+
+ kfree(stbl.rail);
+
return 0;
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/nouveau: Fix memory leak in nvbios_iccsense_parse
2024-12-16 1:52 Zhanxin Qi
@ 2024-12-16 9:45 ` Danilo Krummrich
0 siblings, 0 replies; 3+ messages in thread
From: Danilo Krummrich @ 2024-12-16 9:45 UTC (permalink / raw)
To: Zhanxin Qi
Cc: kherbst, lyude, airlied, simona, dri-devel, nouveau, linux-kernel
Thanks for the patch, some notes below.
On Mon, Dec 16, 2024 at 09:52:46AM +0800, Zhanxin Qi wrote:
> The nvbios_iccsense_parse function allocates memory for sensor data
> but fails to free it when the function exits, leading to a memory
> leak. Add proper cleanup to free the allocated memory.
>
> Signed-off-by: Zhanxin Qi <zhanxin@nfschina.com>
Please also add a "Fixes:" tag and "Cc: stable@vger.kernel.org" for this.
> ---
> drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index 8f0ccd3664eb..502608d575f7 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -291,6 +291,9 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> list_add_tail(&rail->head, &iccsense->rails);
> }
> }
> +
> + kfree(stbl.rail);
I think it's a bit subtile why this is needed here; better add a new inline
function (nvbios_iccsense_cleanup()) to include/nvkm/subdev/bios/iccsense.h that
frees the memory and call this one instead.
While at it, you may also want to send a separate patch, adding a brief comment
to nvbios_iccsense_parse() which notes, that after a successful call to
nvbios_iccsense_parse() it must be cleaned up with nvbios_iccsense_cleanup().
> +
> return 0;
> }
>
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-16 9:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-10 6:20 [PATCH] drm/nouveau: Fix memory leak in nvbios_iccsense_parse zhanxin
2024-12-16 1:52 Zhanxin Qi
2024-12-16 9:45 ` Danilo Krummrich
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®