[<prev] [next>] [day] [month] [year] [list]
Message-ID: <5d5c8c7b-b926-8397-7994-623ac9b37e83@collabora.com>
Date: Wed, 22 Mar 2023 10:36:47 +0100
From: Benjamin Gaignard <benjamin.gaignard@...labora.com>
To: Markus Elfring <Markus.Elfring@....de>,
kernel-janitors@...r.kernel.org, linux-media@...r.kernel.org,
linux-rockchip@...ts.infradead.org,
Adrian Ratiu <adrian.ratiu@...labora.com>,
Ezequiel Garcia <ezequiel@...guardiasur.com.ar>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>
Cc: cocci@...ia.fr, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] media: hantro: HEVC: Fix exception handling in
tile_buffer_reallocate()
Hi Markus,
Thanks for your patch,
Le 20/03/2023 à 19:43, Markus Elfring a écrit :
> Date: Mon, 20 Mar 2023 19:13:20 +0100
>
> The label “err_free_tile_buffers” was used to jump to another pointer
> check despite of the detail in the implementation of the function
> “tile_buffer_reallocate” that it was determined already that
> a corresponding variable contained a null pointer because of a failed
> function call “dma_alloc_coherent”.
>
> * Thus use an additional label instead.
>
> * Delete a redundant check.
>
>
> This issue was detected by using the Coccinelle software.
If you want to optimize the error path I think the best
option is to return -ENOMEM when hevc_dec->tile_filter.cpu is NULL,
remove
if (hevc_dec->tile_bsd.cpu)
dma_free_coherent(vpu->dev, hevc_dec->tile_bsd.size,
hevc_dec->tile_bsd.cpu,
hevc_dec->tile_bsd.dma);
and reorder the two other dma_free to get something clean.
Regards,
Benjamin
>
> Fixes: cb5dd5a0fa518dff14ff2b90837c3c8f98f4dd5c ("media: hantro: Introduce G2/HEVC decoder")
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
> drivers/media/platform/verisilicon/hantro_hevc.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/platform/verisilicon/hantro_hevc.c b/drivers/media/platform/verisilicon/hantro_hevc.c
> index 9383fb7081f6..ac60df18efb7 100644
> --- a/drivers/media/platform/verisilicon/hantro_hevc.c
> +++ b/drivers/media/platform/verisilicon/hantro_hevc.c
> @@ -109,7 +109,7 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
> &hevc_dec->tile_filter.dma,
> GFP_KERNEL);
> if (!hevc_dec->tile_filter.cpu)
> - goto err_free_tile_buffers;
> + goto recheck_tile_sao_cpu;
> hevc_dec->tile_filter.size = size;
>
> size = (VERT_SAO_RAM_SIZE * height64 * (num_tile_cols - 1) * ctx->bit_depth) / 8;
> @@ -133,12 +133,12 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)
> return 0;
>
> err_free_tile_buffers:
> - if (hevc_dec->tile_filter.cpu)
> - dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size,
> - hevc_dec->tile_filter.cpu,
> - hevc_dec->tile_filter.dma);
> + dma_free_coherent(vpu->dev, hevc_dec->tile_filter.size,
> + hevc_dec->tile_filter.cpu,
> + hevc_dec->tile_filter.dma);
> hevc_dec->tile_filter.cpu = NULL;
>
> +recheck_tile_sao_cpu:
> if (hevc_dec->tile_sao.cpu)
> dma_free_coherent(vpu->dev, hevc_dec->tile_sao.size,
> hevc_dec->tile_sao.cpu,
> --
> 2.40.0
>
>
Powered by blists - more mailing lists