watchdog: bcm7038: Check the return value from clk_prepare_enable()
authorFabio Estevam <fabio.estevam@nxp.com>
Sat, 22 Jul 2017 20:22:59 +0000 (17:22 -0300)
committerWim Van Sebroeck <wim@iguana.be>
Sat, 9 Sep 2017 18:52:13 +0000 (20:52 +0200)
clk_prepare_enable() may fail, so we should better check its return value
and propagate it in the case of error.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/bcm7038_wdt.c

index c1b8e534fb5585ad52c2b4d9693981d33b448dff..f88f546e8050048b21719a51cb48ad7ec1556aa7 100644 (file)
@@ -136,7 +136,9 @@ static int bcm7038_wdt_probe(struct platform_device *pdev)
        wdt->clk = devm_clk_get(dev, NULL);
        /* If unable to get clock, use default frequency */
        if (!IS_ERR(wdt->clk)) {
-               clk_prepare_enable(wdt->clk);
+               err = clk_prepare_enable(wdt->clk);
+               if (err)
+                       return err;
                wdt->rate = clk_get_rate(wdt->clk);
                /* Prevent divide-by-zero exception */
                if (!wdt->rate)