Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a20b5e3 authored by Kangjie Lu's avatar Kangjie Lu Committed by Alexandre Belloni
Browse files

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: default avatarKangjie Lu <kjlu@umn.edu>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 5910fa0d
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -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);
	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_sec = bcd2bin(buf[0] & HYM8563_SEC_MASK);
	tm->tm_min = bcd2bin(buf[1] & HYM8563_MIN_MASK);
	tm->tm_min = bcd2bin(buf[1] & HYM8563_MIN_MASK);