Re: [PATCH] drm/panthor: return error on truncated firmware

From: Liviu Dudau

Date: Wed Jul 15 2026 - 06:44:51 EST


On Tue, Jul 14, 2026 at 06:30:55PM +0200, Osama Abdelkader wrote:
> panthor_fw_load() detects truncated firmware images, but jumps to the
> common cleanup path without setting ret. If no previous error was recorded,
> the function can return 0 and treat the invalid firmware as successfully
> loaded.
>
> Set ret to -EINVAL before leaving the truncated-image path.
>
> Fixes: 2718d91816ee ("drm/panthor: Add the FW logical block")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Osama Abdelkader <osama.abdelkader@xxxxxxxxx>

Reviewed-by: Liviu Dudau <liviu.dudau@xxxxxxx>

Thanks for the fix!

Best regards,
Liviu

> ---
> drivers/gpu/drm/panthor/panthor_fw.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c
> index 986151681b24..39fff094ebb5 100644
> --- a/drivers/gpu/drm/panthor/panthor_fw.c
> +++ b/drivers/gpu/drm/panthor/panthor_fw.c
> @@ -829,6 +829,7 @@ static int panthor_fw_load(struct panthor_device *ptdev)
> }
>
> if (hdr.size > iter.size) {
> + ret = -EINVAL;
> drm_err(&ptdev->base, "Firmware image is truncated\n");
> goto out;
> }
> --
> 2.43.0
>

--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯