* [PATCH] rtc: fix a missing check of block data read
@ 2018-12-26 3:09 Kangjie Lu
2019-01-22 18:04 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2018-12-26 3:09 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Alessandro Zummo, Alexandre Belloni, linux-rtc, linux-kernel
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>
---
drivers/rtc/rtc-hym8563.c | 2 ++
1 file changed, 2 insertions(+)
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);
--
2.17.2 (Apple Git-113)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: fix a missing check of block data read
2018-12-26 3:09 [PATCH] rtc: fix a missing check of block data read Kangjie Lu
@ 2019-01-22 18:04 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2019-01-22 18:04 UTC (permalink / raw)
To: Kangjie Lu; +Cc: pakki001, Alessandro Zummo, linux-rtc, linux-kernel
On 25/12/2018 21:09:11-0600, Kangjie Lu wrote:
> 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>
> ---
> drivers/rtc/rtc-hym8563.c | 2 ++
> 1 file changed, 2 insertions(+)
>
Applied, thanks.
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-22 18:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-26 3:09 [PATCH] rtc: fix a missing check of block data read Kangjie Lu
2019-01-22 18:04 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).