Skip to contentSkip to conversation

rtc: da9063: Handle invalid IRQ from platform_get_irq_byname()

RFT Applied Krzysztof Kozlowski 3 participants 3 messages Oct 4, 2019 – Oct 7, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

platform_get_irq_byname() might return -errno which later would be cast to an unsigned int and used in request_irq().

---

Not marking as cc-stable as this was not reproduced and not tested.

---
 drivers/rtc/rtc-da9063.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-da9063.c +3 -0
index 15908d51b1cb..046b1d4c3dae 100644
@@ -483,6 +483,9 @@ static int da9063_rtc_probe(struct platform_device *pdev)
 		rtc->rtc_dev->uie_unsupported = 1;
 
 	irq_alarm = platform_get_irq_byname(pdev, "ALARM");
+	if (irq_alarm < 0)
+		return irq_alarm;
+
 	ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL,
 					da9063_alarm_event,
 					IRQF_TRIGGER_LOW | IRQF_ONESHOT,
Signature · 1 line
2.17.1
Tested-by
#1 lore raw
Quoted 4 lines · Krzysztof Kozlowski

platform_get_irq_byname() might return -errno which later would be cast to an unsigned int and used in request_irq().

This doesn't break the existing RTC functionality when running up on my test board with DA9063. Although very unlikely to occur it does make sense so:

Quoted 24 lines

---

Not marking as cc-stable as this was not reproduced and not tested.

---
 drivers/rtc/rtc-da9063.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-da9063.c +3 -0
index 15908d51b1cb..046b1d4c3dae 100644
@@ -483,6 +483,9 @@ static int da9063_rtc_probe(struct platform_device
 *pdev)
 		rtc->rtc_dev->uie_unsupported = 1;
 
 	irq_alarm = platform_get_irq_byname(pdev, "ALARM");
+	if (irq_alarm < 0)
+		return irq_alarm;
+
 	ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL,
 					da9063_alarm_event,

IRQF_TRIGGER_LOW | IRQF_ONESHOT,
--

maintainer Applied
#2 lore raw
In reply to Krzysztof Kozlowski
Quoted 12 lines · Krzysztof Kozlowski

platform_get_irq_byname() might return -errno which later would be cast to an unsigned int and used in request_irq().

---

Not marking as cc-stable as this was not reproduced and not tested.

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

Applied, thanks.

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com