]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
rtc: hym8563: fix a missing check of block data read
authorKangjie Lu <kjlu@umn.edu>
Wed, 26 Dec 2018 03:09:11 +0000 (21:09 -0600)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Tue, 22 Jan 2019 18:03:43 +0000 (19:03 +0100)
When i2c_smbus_read_i2c_block_data() fails, the read data in "buf" could
be incorrect and should not be used. The fix checks if
i2c_smbus_read_i2c_block_data fails, and if so, return its error code
upstream.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-hym8563.c

index e5ad527cb75e369945a7a533105d6d0d8573ac10..d03f5d212eea841e1003ea49dd8cbe27613590fa 100644 (file)
@@ -109,6 +109,8 @@ static int hym8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
        }
 
        ret = i2c_smbus_read_i2c_block_data(client, HYM8563_SEC, 7, buf);
+       if (ret < 0)
+               return ret;
 
        tm->tm_sec = bcd2bin(buf[0] & HYM8563_SEC_MASK);
        tm->tm_min = bcd2bin(buf[1] & HYM8563_MIN_MASK);