Re: [PATCH] Fix memory leaks in wave5_vpu_open_enc() and wave5_vpu_open_dec()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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;







[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux