Skip to contentSkip to conversation

rtc: as3722: check return value of platform_get_irq()

PATCH New Akshat Rawat 2 participants 2 messages Nov 7

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

PATCH 1/1 rtc: as3722: check return value of platform_get_irq()

In as3722_rtc_probe(), the return value of platform_get_irq() is assigned to as3722_rtc->alarm_irq without error checking.

If platform_get_irq() fails (such as returning -EPROBE_DEFER when the parent interrupt controller is not yet ready), the driver logs an invalid IRQ number in dev_info() and calls devm_request_threaded_irq() with a negative value. This causes devm_request_threaded_irq() to fail with -EINVAL and abort probe permanently, breaking deferred probing.

Check the return value of platform_get_irq() and return immediately on failure to properly propagate errors.

Fixes b45062619840 ("drivers/rtc/rtc-as3722: add RTC driver")
---
 drivers/rtc/rtc-as3722.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-as3722.c +3 -0
index 9682d6457b7f..dfa3628ad95b 100644
@@ -198,6 +198,9 @@ static int as3722_rtc_probe(struct platform_device *pdev)
 	}
 
 	as3722_rtc->alarm_irq = platform_get_irq(pdev, 0);
+	if (as3722_rtc->alarm_irq < 0)
+		return as3722_rtc->alarm_irq;
+
 	dev_info(&pdev->dev, "RTC interrupt %d\n", as3722_rtc->alarm_irq);
 
 	ret = devm_request_threaded_irq(&pdev->dev, as3722_rtc->alarm_irq, NULL,
Signature · 1 line
2.56.0.windows.4
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

In as3722_rtc_probe(), the return value of platform_get_irq() is assigned to as3722_rtc->alarm_irq without error checking.

If platform_get_irq() fails (such as returning -EPROBE_DEFER when the parent interrupt controller is not yet ready), the driver logs an invalid IRQ number in dev_info() and calls devm_request_threaded_irq() with a negative value. This causes devm_request_threaded_irq() to fail with -EINVAL and abort probe permanently, breaking deferred probing.

Quoted 6 lines

Check the return value of platform_get_irq() and return immediately on failure to properly propagate errors.

Fixes b45062619840 ("drivers/rtc/rtc-as3722: add RTC driver")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1