serial: sc16is7xx: Correct initialization of s->clk
authorJon Ringle <jringle@gridpoint.com>
Fri, 25 Jul 2014 17:53:36 +0000 (13:53 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 27 Jul 2014 18:50:38 +0000 (11:50 -0700)
The s->clk never gets setup in sc16is7xx_probe() and instead was using a
local clk variable, but then testing the uninitialized s->clk during
teardown

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sc16is7xx.c

index 914825e034273d7bc2676a73f608399e9dc2ac20..3284c31085a77815117ed0a0bfd280accaae701f 100644 (file)
@@ -1060,7 +1060,6 @@ static int sc16is7xx_probe(struct device *dev,
                           struct regmap *regmap, int irq, unsigned long flags)
 {
        unsigned long freq, *pfreq = dev_get_platdata(dev);
-       struct clk *clk;
        int i, ret;
        struct sc16is7xx_port *s;
 
@@ -1076,14 +1075,14 @@ static int sc16is7xx_probe(struct device *dev,
                return -ENOMEM;
        }
 
-       clk = devm_clk_get(dev, NULL);
-       if (IS_ERR(clk)) {
+       s->clk = devm_clk_get(dev, NULL);
+       if (IS_ERR(s->clk)) {
                if (pfreq)
                        freq = *pfreq;
                else
-                       return PTR_ERR(clk);
+                       return PTR_ERR(s->clk);
        } else {
-               freq = clk_get_rate(clk);
+               freq = clk_get_rate(s->clk);
        }
 
        s->regmap = regmap;