* [PATCH] media: vidtv: Add the missing kfree to avoid the memory leak
@ 2022-01-12 2:03 Jiasheng Jiang
0 siblings, 0 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2022-01-12 2:03 UTC (permalink / raw)
To: hverkuil, dwlsalmeida, mchehab; +Cc: linux-media, linux-kernel, Jiasheng Jiang
Since kstrdup() allocate a space for e->name and will not automatically
free.
If kzalloc() fails, we just kfree e without e->name.
Then we cannot get the pointer 'e->name' and cause the memory leak.
Fixes: 3d1387b3b8f6 ("media: vidtv: fix some warnings")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/media/test-drivers/vidtv/vidtv_s302m.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
index ddaff46c440f..433fc0c7fdfa 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
@@ -474,6 +474,7 @@ struct vidtv_encoder
ctx = kzalloc(priv_sz, GFP_KERNEL);
if (!ctx) {
+ kfree(e->name);
kfree(e);
return NULL;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: vidtv: Add the missing kfree to avoid the memory leak
2022-01-12 2:05 Jiasheng Jiang
@ 2022-01-13 10:09 ` Hans Verkuil
0 siblings, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2022-01-13 10:09 UTC (permalink / raw)
To: Jiasheng Jiang, dwlsalmeida, mchehab; +Cc: linux-media, linux-kernel
On 12/01/2022 03:05, Jiasheng Jiang wrote:
> Since kstrdup() allocate a space for e->name and will not automatically
> free.
> If kzalloc() fails, we just kfree e without e->name.
> Then we cannot get the pointer 'e->name' and cause the memory leak.
>
> Fixes: 3d1387b3b8f6 ("media: vidtv: fix some warnings")
> Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> drivers/media/test-drivers/vidtv/vidtv_s302m.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
> index ddaff46c440f..433fc0c7fdfa 100644
> --- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c
> +++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
> @@ -474,6 +474,7 @@ struct vidtv_encoder
>
> ctx = kzalloc(priv_sz, GFP_KERNEL);
> if (!ctx) {
> + kfree(e->name);
It should also free e->encoder_buf.
Regards,
Hans
> kfree(e);
> return NULL;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] media: vidtv: Add the missing kfree to avoid the memory leak
@ 2022-01-12 2:05 Jiasheng Jiang
2022-01-13 10:09 ` Hans Verkuil
0 siblings, 1 reply; 3+ messages in thread
From: Jiasheng Jiang @ 2022-01-12 2:05 UTC (permalink / raw)
To: hverkuil, dwlsalmeida, mchehab; +Cc: linux-media, linux-kernel, Jiasheng Jiang
Since kstrdup() allocate a space for e->name and will not automatically
free.
If kzalloc() fails, we just kfree e without e->name.
Then we cannot get the pointer 'e->name' and cause the memory leak.
Fixes: 3d1387b3b8f6 ("media: vidtv: fix some warnings")
Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/media/test-drivers/vidtv/vidtv_s302m.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
index ddaff46c440f..433fc0c7fdfa 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
@@ -474,6 +474,7 @@ struct vidtv_encoder
ctx = kzalloc(priv_sz, GFP_KERNEL);
if (!ctx) {
+ kfree(e->name);
kfree(e);
return NULL;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-13 10:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 2:03 [PATCH] media: vidtv: Add the missing kfree to avoid the memory leak Jiasheng Jiang
2022-01-12 2:05 Jiasheng Jiang
2022-01-13 10:09 ` Hans Verkuil
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.