serial: of_serial: check the return value of clk_prepare_enable()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 25 May 2015 06:03:32 +0000 (15:03 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 21:55:12 +0000 (06:55 +0900)
The function clk_prepare_enable() may fail, and in that case it
does not make sense to proceed.  Let's check its return code and
error out if it is a negative value.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/of_serial.c

index d353fdf55ac19e156f3e0d56fd48b3b31f6c2b07..6823df99bd7685db295b94599e6bd1b7f7a78057 100644 (file)
@@ -74,7 +74,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
                        return PTR_ERR(info->clk);
                }
 
-               clk_prepare_enable(info->clk);
+               ret = clk_prepare_enable(info->clk);
+               if (ret < 0)
+                       return ret;
+
                clk = clk_get_rate(info->clk);
        }
        /* If current-speed was set, then try not to change it. */