Skip to content

Commit

Permalink
pinctrl: freescale: imx: fix bogus check of of_iomap() return value
Browse files Browse the repository at this point in the history
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: 26d8cde ("pinctrl: freescale: imx: add shared input select reg support")
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Acked-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Vladimir Zapolskiy authored and Linus Walleij committed Mar 30, 2016
1 parent 5e7515b commit 9a4f424
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions drivers/pinctrl/freescale/pinctrl-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,19 +762,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);
Expand Down

0 comments on commit 9a4f424

Please sign in to comment.