Re: [PATCH v2 2/2] staging: greybus: bootrom: fix potential null pointer dereference
From: Dan Carpenter
Date: Mon Mar 16 2026 - 05:05:21 EST
On Mon, Mar 16, 2026 at 07:19:49AM +0800, Oarora Etimis wrote:
> In gb_bootrom_get_firmware(), the 'fw' pointer could be NULL if the
> function jumps to the 'unlock' label. The execution flow continues
> into the 'queue_work' block where 'fw->size' is accessed, leading to
> a null pointer dereference.
>
> Fix this by adding a NULL check for 'fw' before accessing its members.
>
> Signed-off-by: Oarora Etimis <OaroraEtimis@xxxxxxxxx>
> ---
> Changes in v2:
> - Rebased onto the latest staging-next branch to resolve merge conflicts.
> - No logical code changes.
>
> drivers/staging/greybus/bootrom.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c
> index 83921d90c322..50c80475d241 100644
> --- a/drivers/staging/greybus/bootrom.c
> +++ b/drivers/staging/greybus/bootrom.c
> @@ -298,7 +298,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op)
>
> queue_work:
> /* Refresh timeout */
> - if (!ret && (offset + size == fw->size))
> + if (!ret && fw && (offset + size == fw->size))
This seems like a static checker false positive.
regards,
dan carpenter