[PATCH] media: hantro: HEVC: Fix exception handling in tile_buffer_reallocate()

Markus Elfring Markus.Elfring at web.de
Wed Mar 22 07:45:21 PDT 2023

>> 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 would find it nice if more contributors can pick such an idea up.

> 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.

It seems that my understanding was too limited so far for possible improvements
of this function implementation.

Would you like to apply any other design variant?


More information about the Linux-rockchip mailing list