summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-hym8563.c
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2018-12-25 21:09:11 -0600
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2019-01-22 19:03:43 +0100
commit9a20b5e35a536d6bb4b2d4a3b14a0457e205356c (patch)
tree2e9c4093c1e645bb9784df16383f292cac1ab43b /drivers/rtc/rtc-hym8563.c
parent5910fa0d0d9809c4d8fbf1fb905a8c86fbf2eccb (diff)
downloadlwn-9a20b5e35a536d6bb4b2d4a3b14a0457e205356c.tar.gz
lwn-9a20b5e35a536d6bb4b2d4a3b14a0457e205356c.zip
rtc: hym8563: fix a missing check of block data read
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>
Diffstat (limited to 'drivers/rtc/rtc-hym8563.c')
-rw-r--r--drivers/rtc/rtc-hym8563.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index e5ad527cb75e..d03f5d212eea 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -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);