Commit 2e638de5 authored by Vladimir Zapolskiy's avatar Vladimir Zapolskiy Committed by Greg Kroah-Hartman

pinctrl: freescale: imx: fix bogus check of of_iomap() return value

commit 9a4f4245 upstream.

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: 26d8cde5 ("pinctrl: freescale: imx: add shared input select reg support")
Signed-off-by: default avatarVladimir Zapolskiy <vz@mleia.com>
Acked-by: default avatarShawn Guo <shawnguo@kernel.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e7c6abc4
...@@ -726,19 +726,18 @@ int imx_pinctrl_probe(struct platform_device *pdev, ...@@ -726,19 +726,18 @@ int imx_pinctrl_probe(struct platform_device *pdev,
if (of_property_read_bool(dev_np, "fsl,input-sel")) { if (of_property_read_bool(dev_np, "fsl,input-sel")) {
np = of_parse_phandle(dev_np, "fsl,input-sel", 0); np = of_parse_phandle(dev_np, "fsl,input-sel", 0);
if (np) { if (!np) {
dev_err(&pdev->dev, "iomuxc fsl,input-sel property not found\n");
return -EINVAL;
}
ipctl->input_sel_base = of_iomap(np, 0); ipctl->input_sel_base = of_iomap(np, 0);
if (IS_ERR(ipctl->input_sel_base)) {
of_node_put(np); of_node_put(np);
if (!ipctl->input_sel_base) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"iomuxc input select base address not found\n"); "iomuxc input select base address not found\n");
return PTR_ERR(ipctl->input_sel_base); return -ENOMEM;
}
} else {
dev_err(&pdev->dev, "iomuxc fsl,input-sel property not found\n");
return -EINVAL;
} }
of_node_put(np);
} }
imx_pinctrl_desc.name = dev_name(&pdev->dev); imx_pinctrl_desc.name = dev_name(&pdev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment