All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: freescale: imx: fix bogus check of of_iomap() return value
@ 2016-03-09  0:45 Vladimir Zapolskiy
  2016-03-15  9:00 ` Shawn Guo
  2016-03-16 12:57 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Zapolskiy @ 2016-03-09  0:45 UTC (permalink / raw
  To: Linus Walleij; +Cc: Shawn Guo, Adrian Alonso, linux-gpio

On error path of_iomap() returns NULL, hence IS_ERR() check is invalid
and may cause a NULL pointer dereference, the change fixes this
problem.

While we are here invert a device node check to simplify the code.

Fixes: 26d8cde5260b ("pinctrl: freescale: imx: add shared input select reg support")
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
 drivers/pinctrl/freescale/pinctrl-imx.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 4c435cf..b2d0ac7 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -752,19 +752,18 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 
 	if (of_property_read_bool(dev_np, "fsl,input-sel")) {
 		np = of_parse_phandle(dev_np, "fsl,input-sel", 0);
-		if (np) {
-			ipctl->input_sel_base = of_iomap(np, 0);
-			if (IS_ERR(ipctl->input_sel_base)) {
-				of_node_put(np);
-				dev_err(&pdev->dev,
-					"iomuxc input select base address not found\n");
-				return PTR_ERR(ipctl->input_sel_base);
-			}
-		} else {
+		if (!np) {
 			dev_err(&pdev->dev, "iomuxc fsl,input-sel property not found\n");
 			return -EINVAL;
 		}
+
+		ipctl->input_sel_base = of_iomap(np, 0);
 		of_node_put(np);
+		if (!ipctl->input_sel_base) {
+			dev_err(&pdev->dev,
+				"iomuxc input select base address not found\n");
+			return -ENOMEM;
+		}
 	}
 
 	imx_pinctrl_desc.name = dev_name(&pdev->dev);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: freescale: imx: fix bogus check of of_iomap() return value
  2016-03-09  0:45 [PATCH] pinctrl: freescale: imx: fix bogus check of of_iomap() return value Vladimir Zapolskiy
@ 2016-03-15  9:00 ` Shawn Guo
  2016-03-16 12:57 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2016-03-15  9:00 UTC (permalink / raw
  To: Vladimir Zapolskiy; +Cc: Linus Walleij, Adrian Alonso, linux-gpio

On Wed, Mar 09, 2016 at 02:45:36AM +0200, Vladimir Zapolskiy wrote:
> On error path of_iomap() returns NULL, hence IS_ERR() check is invalid
> and may cause a NULL pointer dereference, the change fixes this
> problem.
> 
> While we are here invert a device node check to simplify the code.
> 
> Fixes: 26d8cde5260b ("pinctrl: freescale: imx: add shared input select reg support")
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>

Acked-by: Shawn Guo <shawnguo@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: freescale: imx: fix bogus check of of_iomap() return value
  2016-03-09  0:45 [PATCH] pinctrl: freescale: imx: fix bogus check of of_iomap() return value Vladimir Zapolskiy
  2016-03-15  9:00 ` Shawn Guo
@ 2016-03-16 12:57 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2016-03-16 12:57 UTC (permalink / raw
  To: Vladimir Zapolskiy; +Cc: Shawn Guo, Adrian Alonso, linux-gpio@vger.kernel.org

On Wed, Mar 9, 2016 at 1:45 AM, Vladimir Zapolskiy <vz@mleia.com> wrote:

> On error path of_iomap() returns NULL, hence IS_ERR() check is invalid
> and may cause a NULL pointer dereference, the change fixes this
> problem.
>
> While we are here invert a device node check to simplify the code.
>
> Fixes: 26d8cde5260b ("pinctrl: freescale: imx: add shared input select reg support")
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>

Patch applied with Shawn's ACK.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-16 12:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-09  0:45 [PATCH] pinctrl: freescale: imx: fix bogus check of of_iomap() return value Vladimir Zapolskiy
2016-03-15  9:00 ` Shawn Guo
2016-03-16 12:57 ` Linus Walleij

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.