lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a097944d068ecc8e1121350bb7dffb058859f032.camel@collabora.com>
Date:   Mon, 04 Dec 2023 08:54:37 -0500
From:   Nicolas Dufresne <nicolas.dufresne@...labora.com>
To:     Zeng Chi <zengchi@...inos.cn>, nas.chung@...psnmedia.com,
        jackson.lee@...psnmedia.com, mchehab@...nel.org,
        sebastian.fricke@...labora.com, hverkuil-cisco@...all.nl,
        bob.beckett@...labora.com
Cc:     linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Fix memory leaks in wave5_vpu_open_enc() and
 wave5_vpu_open_dec()

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@...inos.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;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ