From: Ray Jui <ray.jui@broadcom.com>
To: Young Xiao <92siuyang@gmail.com>,
rjui@broadcom.com, sbranden@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, linus.walleij@linaro.org,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: ns2: Fix potential NULL dereference
Date: Thu, 30 May 2019 17:17:28 -0700 [thread overview]
Message-ID: <ace57d13-6194-df8e-d2e8-fbc85d9ce21a@broadcom.com> (raw)
In-Reply-To: <1559097838-26070-1-git-send-email-92siuyang@gmail.com>
On 5/28/2019 7:43 PM, Young Xiao wrote:
> platform_get_resource() may fail and return NULL, so we should
> better check it's return value to avoid a NULL pointer dereference
> a bit later in the code.
>
> Signed-off-by: Young Xiao <92siuyang@gmail.com>
> ---
> drivers/pinctrl/bcm/pinctrl-ns2-mux.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pinctrl/bcm/pinctrl-ns2-mux.c b/drivers/pinctrl/bcm/pinctrl-ns2-mux.c
> index 4b5cf0e..2bf6af7 100644
> --- a/drivers/pinctrl/bcm/pinctrl-ns2-mux.c
> +++ b/drivers/pinctrl/bcm/pinctrl-ns2-mux.c
> @@ -1048,6 +1048,8 @@ static int ns2_pinmux_probe(struct platform_device *pdev)
> return PTR_ERR(pinctrl->base0);
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + if (!res)
> + return -EINVAL;
Right, usually not needed if devm_ioremap_resource is used since it was
checked there. But in this case, I do think it needs to be checked. This
change looks good to me. Thanks.
> pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
> resource_size(res));
> if (!pinctrl->base1) {
>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
next prev parent reply other threads:[~2019-05-31 0:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-29 2:43 Young Xiao
2019-05-31 0:17 ` Ray Jui [this message]
2019-06-07 21:06 ` Linus Walleij
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=ace57d13-6194-df8e-d2e8-fbc85d9ce21a@broadcom.com \
--to=ray.jui@broadcom.com \
--cc=92siuyang@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®