* [PATCH] pinctrl: ns2: Fix potential NULL dereference
@ 2019-05-29 2:43 Young Xiao
2019-05-31 0:17 ` Ray Jui
2019-06-07 21:06 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Young Xiao @ 2019-05-29 2:43 UTC (permalink / raw)
To: rjui, sbranden, bcm-kernel-feedback-list, linus.walleij,
linux-arm-kernel, linux-gpio, linux-kernel
Cc: Young Xiao
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;
pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
resource_size(res));
if (!pinctrl->base1) {
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: ns2: Fix potential NULL dereference
2019-05-29 2:43 [PATCH] pinctrl: ns2: Fix potential NULL dereference Young Xiao
@ 2019-05-31 0:17 ` Ray Jui
2019-06-07 21:06 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Ray Jui @ 2019-05-31 0:17 UTC (permalink / raw)
To: Young Xiao, rjui, sbranden, bcm-kernel-feedback-list,
linus.walleij, linux-arm-kernel, linux-gpio, linux-kernel
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>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: ns2: Fix potential NULL dereference
2019-05-29 2:43 [PATCH] pinctrl: ns2: Fix potential NULL dereference Young Xiao
2019-05-31 0:17 ` Ray Jui
@ 2019-06-07 21:06 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2019-06-07 21:06 UTC (permalink / raw)
To: Young Xiao
Cc: Scott Branden, Ray Jui, linux-kernel, open list:GPIO SUBSYSTEM,
bcm-kernel-feedback-list, Linux ARM
On Wed, May 29, 2019 at 4:42 AM Young Xiao <92siuyang@gmail.com> 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>
Patch applied with Ray's ACK.
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-07 21:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29 2:43 [PATCH] pinctrl: ns2: Fix potential NULL dereference Young Xiao
2019-05-31 0:17 ` Ray Jui
2019-06-07 21:06 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).