diff options
author | Jia-Ju Bai <baijiaju1990@gmail.com> | 2017-12-13 16:56:04 +0300 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2018-01-12 02:20:34 +0300 |
commit | 298c8545206b2dd963079ff48fafd909e099856e (patch) | |
tree | b8d9e8a26bf916072856f5f9865dc680162bc49e | |
parent | cd8c0bb2bd57c48c451ebea86065257ef2500b00 (diff) | |
download | linux-298c8545206b2dd963079ff48fafd909e099856e.tar.xz |
rtc: r7301: Fix a possible sleep-in-atomic bug in rtc7301_set_time
The driver may sleep under a spinlock.
The function call path is:
rtc7301_set_time (acquire the spinlock)
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 d846e9703ad6..500e8c8a2605 100644 --- a/drivers/rtc/rtc-r7301.c +++ b/drivers/rtc/rtc-r7301.c @@ -235,7 +235,7 @@ static int rtc7301_set_time(struct device *dev, struct rtc_time *tm) spin_lock_irqsave(&priv->lock, flags); rtc7301_stop(priv); - usleep_range(200, 300); + udelay(300); rtc7301_select_bank(priv, 0); rtc7301_write_time(priv, tm, false); rtc7301_start(priv); |