Patchwork rtc: verify a critical argument to rtc_update_irq() before using it

login
register
mail settings
Submitter Alessandro Zummo
Date March 3, 2014, 6:40 p.m.
Message ID <20140303194050.78df18eb@linux.lan.towertech.it>
Download mbox | patch
Permalink /patch/325972/
State New
Headers show

Comments

Alessandro Zummo - March 3, 2014, 6:40 p.m.
This small addition to the core simplifies code
in the drivers and makes them more robust when handling
shared IRQs.

Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Shiyan <shc_work@mail.ru>

---
 drivers/rtc/interface.c | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 544be72..c2eff60 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -584,6 +584,9 @@  enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)
 void rtc_update_irq(struct rtc_device *rtc,
 		unsigned long num, unsigned long events)
 {
+	if (unlikely(IS_ERR_OR_NULL(rtc)))
+		return;
+
 	pm_stay_awake(rtc->dev.parent);
 	schedule_work(&rtc->irqwork);
 }