From: Dan Carpenter <dan.carpenter@linaro.org>
To: Oarora Etimis <oaroraetimis@gmail.com>
Cc: vireshk@kernel.org, gregkh@linuxfoundation.org, johan@kernel.org,
elder@kernel.org, greybus-dev@lists.linaro.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: greybus: bootrom: fix potential null pointer dereference
Date: Mon, 16 Mar 2026 11:58:50 +0300 [thread overview]
Message-ID: <abfGStu_eSV0xcM6@stanley.mountain> (raw)
In-Reply-To: <20260315182028.133028-1-OaroraEtimis@gmail.com>
On Mon, Mar 16, 2026 at 02:20:28AM +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@gmail.com>
> ---
> 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))
Was this a static checker false positive? Which checker are you using?
If fw is NULL then "ret" is a negative error code so the original code
is fine.
regards,
dan carpenter
> next_request = NEXT_REQ_READY_TO_BOOT;
> else
> next_request = NEXT_REQ_GET_FIRMWARE;
> --
> 2.47.3
>
prev parent reply other threads:[~2026-03-16 8:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-15 18:20 [PATCH] staging: greybus: bootrom: fix potential null pointer dereference Oarora Etimis
2026-03-16 8:58 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=abfGStu_eSV0xcM6@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=oaroraetimis@gmail.com \
--cc=vireshk@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.