From: Johan Hovold <johan@kernel.org>
To: Ding Xiang <dingxiang@cmss.chinamobile.com>
Cc: johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org,
greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org,
Viresh Kumar <viresh.kumar@linaro.org>
Subject: Re: [PATCH] staging: greybus: Fix null pointer dereference
Date: Fri, 24 Aug 2018 08:29:30 +0200 [thread overview]
Message-ID: <20180824062930.GS14967@localhost> (raw)
In-Reply-To: <1535083631-1892-1-git-send-email-dingxiang@cmss.chinamobile.com>
On Fri, Aug 24, 2018 at 12:07:11AM -0400, Ding Xiang wrote:
> If fw is null then fw->size will trigger null pointer dereference
>
> Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.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 e85ffae..3af28a0 100644
> --- a/drivers/staging/greybus/bootrom.c
> +++ b/drivers/staging/greybus/bootrom.c
> @@ -297,7 +297,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))
> next_request = NEXT_REQ_READY_TO_BOOT;
> else
> next_request = NEXT_REQ_GET_FIRMWARE;
How could fw be NULL when ret is 0 here?
It may not be as obvious as one might have wished, but the current code
looks correct to me.
Johan
next prev parent reply other threads:[~2018-08-24 6:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-24 4:07 [PATCH] staging: greybus: Fix null pointer dereference Ding Xiang
2018-08-24 6:29 ` Johan Hovold [this message]
2018-08-24 10:08 ` Ding Xiang
2018-08-24 10:27 ` Dan Carpenter
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=20180824062930.GS14967@localhost \
--to=johan@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=dingxiang@cmss.chinamobile.com \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viresh.kumar@linaro.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.