diff options
author | Jia-Ju Bai <baijiaju1990@gmail.com> | 2017-12-13 14:55:50 +0100 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2018-01-12 00:20:28 +0100 |
commit | cd8c0bb2bd57c48c451ebea86065257ef2500b00 (patch) | |
tree | 4eb179a50caab10d3ababa0a7f3b6358ae74a8f7 | |
parent | rtc: omap: fix unbalanced clk_prepare_enable/clk_disable_unprepare (diff) | |
download | linux-cd8c0bb2bd57c48c451ebea86065257ef2500b00.tar.xz linux-cd8c0bb2bd57c48c451ebea86065257ef2500b00.zip |
rtc: r7301: Fix a possible sleep-in-atomic bug in rtc7301_read_time
The driver may sleep under a spinlock.
The function call path is:
rtc7301_read_time (acquire the spinlock)
rtc7301_wait_while_busy
usleep_range --> may sleep
To fix it, usleep_range is replaced with udelay.
This bug is found by my static analysis tool(DSAC) and checked by my code review.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
-rw-r--r-- | drivers/rtc/rtc-r7301.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-r7301.c b/drivers/rtc/rtc-r7301.c index 28d540885f3d..d846e9703ad6 100644 --- a/drivers/rtc/rtc-r7301.c +++ b/drivers/rtc/rtc-r7301.c @@ -95,7 +95,7 @@ static int rtc7301_wait_while_busy(struct rtc7301_priv *priv) if (!(val & RTC7301_CONTROL_BUSY)) return 0; - usleep_range(200, 300); + udelay(300); } return -ETIMEDOUT; |