summaryrefslogtreecommitdiff
path: root/drivers/rtc/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/dev.c')
-rw-r--r--drivers/rtc/dev.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c
index baf1a8ca8b2b..8ba7c25d2565 100644
--- a/drivers/rtc/dev.c
+++ b/drivers/rtc/dev.c
@@ -195,7 +195,16 @@ static __poll_t rtc_dev_poll(struct file *file, poll_table *wait)
poll_wait(file, &rtc->irq_queue, wait);
- data = rtc->irq_data;
+ /*
+ * This read can race with the write in rtc_handle_legacy_irq().
+ *
+ * - If this check misses a zero to non-zero transition the next check
+ * will pick it up (rtc_handle_legacy_irq() wakes up rtc->irq_queue).
+ * - Non-zero to non-zero transition misses do not change return value.
+ * - And a non-zero to zero transition is unlikely to be missed, since
+ * it occurs on rtc_dev_read(), during which polling is not expected.
+ */
+ data = data_race(rtc->irq_data);
return (data != 0) ? (EPOLLIN | EPOLLRDNORM) : 0;
}