serial: max310x: set default value when reading clock ready bit
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Tue, 16 Jan 2024 21:29:58 +0000 (16:29 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jan 2024 03:09:09 +0000 (19:09 -0800)
If regmap_read() returns a non-zero value, the 'val' variable can be left
uninitialized.

Clear it before calling regmap_read() to make sure we properly detect
the clock ready bit.

Fixes: 4cf9a888fd3c ("serial: max310x: Check the clock readiness")
Cc: stable@vger.kernel.org
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20240116213001.3691629-2-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/max310x.c

index f3a99daebdaa0e59d0d81211fad5a1f85947b011..b2c753ba9cbfd0d296a5cdf49deb36392064051e 100644 (file)
@@ -641,7 +641,7 @@ static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
 
        /* Wait for crystal */
        if (xtal) {
-               unsigned int val;
+               unsigned int val = 0;
                msleep(10);
                regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val);
                if (!(val & MAX310X_STS_CLKREADY_BIT)) {