The first DT gpio is necessary for this driver, but errors returned for
of_get_gpio are ignored.

This patch adds a return value check for the first of_get_gpio.

Signed-off-by: Markus Pargmann <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
---
 drivers/w1/masters/w1-gpio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index f54ece2..ae53e88 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -58,6 +58,7 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
 {
        struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
        struct device_node *np = pdev->dev.of_node;
+       int gpio;
 
        pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
@@ -66,7 +67,11 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
        if (of_get_property(np, "linux,open-drain", NULL))
                pdata->is_open_drain = 1;
 
-       pdata->pin = of_get_gpio(np, 0);
+       gpio = of_get_gpio(np, 0);
+       if (gpio < 0)
+               return gpio;
+       pdata->pin = gpio;
+
        pdata->ext_pullup_enable_pin = of_get_gpio(np, 1);
        pdev->dev.platform_data = pdata;
 
-- 
1.8.4.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to