Skip to content

Commit

Permalink
rtc: hym8563: fix a missing check of block data read
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kangjie Lu authored and Alexandre Belloni committed Jan 22, 2019
1 parent 5910fa0 commit 9a20b5e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/rtc/rtc-hym8563.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9a20b5e

Please sign in to comment.