Skip to contentSkip to conversation

rtc: atcrtc100: Fix signedness bug in probe()

PATCH Applied Dan Carpenter 3 participants 4 messages Nov 18, 2025 – Dec 8, 2025

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

PATCH 1/1 rtc: atcrtc100: Fix signedness bug in probe()

The "atcrtc_dev->alarm_irq" variable is an unsigned int but it needs to be signed for the error handling to work. Use the "ret" variable instead.

Fixes 7adca706fe16 ("rtc: atcrtc100: Add ATCRTC100 RTC driver")
---
 drivers/rtc/rtc-atcrtc100.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/rtc/rtc-atcrtc100.c +5 -3
index 51933ae1a2fa..9808fc2c5a49 100644
@@ -296,10 +296,12 @@ static int atcrtc_probe(struct platform_device *pdev)
 				     "Failed to initialize RTC: unsupported hardware ID 0x%x\n",
 				     rtc_id);
 
-	atcrtc_dev->alarm_irq = platform_get_irq(pdev, 1);
-	if (atcrtc_dev->alarm_irq < 0)
-		return dev_err_probe(&pdev->dev, atcrtc_dev->alarm_irq,
+	ret = platform_get_irq(pdev, 1);
+	if (ret < 0)
+		return dev_err_probe(&pdev->dev, ret,
 				     "Failed to get IRQ for alarm\n");
+	atcrtc_dev->alarm_irq = ret;
+
 	ret = devm_request_irq(&pdev->dev,
 			       atcrtc_dev->alarm_irq,
 			       atcrtc_alarm_isr,
Signature · 1 line
2.51.0
maintainer
#1 lore raw

On Tue, Nov 18, 2025 at 01:48:56PM +0300, Dan Carpenter wrote:

Hi Dan,

Thank you for pointing out the issue and for providing the fix.

You're absolutely correct that using an unsigned type for alarm_irq prevents proper error handling when platform_get_irq() returns a negative value. I will apply your patch and also review other return value checks to ensure there are no similar issues elsewhere.

Thank you again for your detailed review and suggestions.

Best regards,
CL

Quoted 34 lines

The "atcrtc_dev->alarm_irq" variable is an unsigned int but it needs to be signed for the error handling to work. Use the "ret" variable instead.

Fixes 7adca706fe16 ("rtc: atcrtc100: Add ATCRTC100 RTC driver")
---
 drivers/rtc/rtc-atcrtc100.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/rtc/rtc-atcrtc100.c +5 -4
index 51933ae1a2fa..9808fc2c5a49 100644
@@ -296,10 +296,12 @@ static int atcrtc_probe(struct platform_device *pdev)
                                     "Failed to initialize RTC: unsupported hardware ID 0x%x\n",
                                     rtc_id);
 
-       atcrtc_dev->alarm_irq = platform_get_irq(pdev, 1);
-       if (atcrtc_dev->alarm_irq < 0)
-               return dev_err_probe(&pdev->dev, atcrtc_dev->alarm_irq,
+       ret = platform_get_irq(pdev, 1);
+       if (ret < 0)
+               return dev_err_probe(&pdev->dev, ret,
                                     "Failed to get IRQ for alarm\n");
+       atcrtc_dev->alarm_irq = ret;
+
        ret = devm_request_irq(&pdev->dev,
                               atcrtc_dev->alarm_irq,
                               atcrtc_alarm_isr,
--

2.51.0

#2 lore raw
Quoted 4 lines · CL Wang

On Tue, Nov 18, 2025 at 01:48:56PM +0300, Dan Carpenter wrote:

Hi Dan,

Quoted 9 lines

Thank you for pointing out the issue and for providing the fix.

You're absolutely correct that using an unsigned type for alarm_irq prevents proper error handling when platform_get_irq() returns a negative value. I will apply your patch and also review other return value checks to ensure there are no similar issues elsewhere.

Thank you again for your detailed review and suggestions.

You're welcome. These are just Smatch warnings. Nothing super major.

https://github.com/error27/smatch
https://github.com/error27/smatch/blob/master/Documentation/smatch.rst

regards,
dan carpenter

maintainer Applied
#3 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

The "atcrtc_dev->alarm_irq" variable is an unsigned int but it needs to be signed for the error handling to work. Use the "ret" variable instead.

Applied, thanks!

[1/1] rtc: atcrtc100: Fix signedness bug in probe()

      https://git.kernel.org/abelloni/c/159a740c768e

Best regards,

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