From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Zeng Chi <zengchi@kylinos.cn>,
nas.chung@chipsnmedia.com, jackson.lee@chipsnmedia.com,
mchehab@kernel.org, sebastian.fricke@collabora.com,
hverkuil-cisco@xs4all.nl, bob.beckett@collabora.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix memory leaks in wave5_vpu_open_enc() and wave5_vpu_open_dec()
Date: Mon, 04 Dec 2023 08:54:37 -0500 [thread overview]
Message-ID: <a097944d068ecc8e1121350bb7dffb058859f032.camel@collabora.com> (raw)
In-Reply-To: <20231204083957.2835095-1-zengchi@kylinos.cn>
Hi,
Le lundi 04 décembre 2023 à 16:39 +0800, Zeng Chi a écrit :
> This patch fixes memory leaks on error escapes in wave5_vpu_open_enc()
> and wave5_vpu_open_dec().
>
> Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
> Signed-off-by: Zeng Chi <zengchi@kylinos.cn>
> ---
> drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 4 +++-
> drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 4 +++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> index 8b1417ece96e..2d3e8a184f93 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> @@ -1792,8 +1792,10 @@ static int wave5_vpu_open_dec(struct file *filp)
> int ret = 0;
>
> inst = kzalloc(sizeof(*inst), GFP_KERNEL);
> - if (!inst)
> + if (!inst) {
> + kfree(inst);
The allocation failed, there is nothing to free here (kfree(null) is a no-op).
This patch does not do what it pretends to do.
Nicolas
> return -ENOMEM;
> + }
>
> inst->dev = dev;
> inst->type = VPU_INST_TYPE_DEC;
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> index f29cfa3af94a..cbf6cb6e07aa 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> @@ -1537,8 +1537,10 @@ static int wave5_vpu_open_enc(struct file *filp)
> int ret = 0;
>
> inst = kzalloc(sizeof(*inst), GFP_KERNEL);
> - if (!inst)
> + if (!inst) {
> + kfree(inst);
> return -ENOMEM;
> + }
> v4l2_ctrl_hdl = &inst->v4l2_ctrl_hdl;
>
> inst->dev = dev;
next prev parent reply other threads:[~2023-12-04 13:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 8:39 [PATCH] Fix memory leaks in wave5_vpu_open_enc() and wave5_vpu_open_dec() Zeng Chi
2023-12-04 13:54 ` Nicolas Dufresne [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-12-04 9:16 Zeng Chi
2023-12-04 13:55 ` Nicolas Dufresne
2023-12-05 17:36 ` Robert Beckett
2023-12-07 18:40 ` Nicolas Dufresne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a097944d068ecc8e1121350bb7dffb058859f032.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--cc=bob.beckett@collabora.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jackson.lee@chipsnmedia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=nas.chung@chipsnmedia.com \
--cc=sebastian.fricke@collabora.com \
--cc=zengchi@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.