From: Young Xiao <92siuyang@gmail.com> Date: Wed, 29 May 2019 02:43:58 +0000 (+0800) Subject: pinctrl: ns2: Fix potential NULL dereference X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f38b5069234937ae818d6a39fd4dc03d003b5565;p=linux.git pinctrl: ns2: Fix potential NULL dereference 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> Reviewed-by: Ray Jui Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/bcm/pinctrl-ns2-mux.c b/drivers/pinctrl/bcm/pinctrl-ns2-mux.c index 4b5cf0e0f16e2..2bf6af7df7d94 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) {