pinctrl: freescale: imx: Use 'devm_of_iomap()' to avoid a resource leak in case of...
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Tue, 2 Jun 2020 20:06:26 +0000 (22:06 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 3 Jun 2020 12:35:41 +0000 (14:35 +0200)
Use 'devm_of_iomap()' instead 'of_iomap()' to avoid a resource leak in
case of error.

Update the error handling code accordingly.

Fixes: 26d8cde5260b ("pinctrl: freescale: imx: add shared input select reg support")
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200602200626.677981-1-christophe.jaillet@wanadoo.fr
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/freescale/pinctrl-imx.c

index 1f81569c7ae3b50b769484e3d933b8fe45897ef8..cb7e0f08d2cf416b6f86ad55c1899d60248760c8 100644 (file)
@@ -824,12 +824,13 @@ int imx_pinctrl_probe(struct platform_device *pdev,
                                return -EINVAL;
                        }
 
-                       ipctl->input_sel_base = of_iomap(np, 0);
+                       ipctl->input_sel_base = devm_of_iomap(&pdev->dev, np,
+                                                             0, NULL);
                        of_node_put(np);
-                       if (!ipctl->input_sel_base) {
+                       if (IS_ERR(ipctl->input_sel_base)) {
                                dev_err(&pdev->dev,
                                        "iomuxc input select base address not found\n");
-                               return -ENOMEM;
+                               return PTR_ERR(ipctl->input_sel_base);
                        }
                }
        }