watchdog: sama5d4_wdt: use platform_get_irq()
Subsystems (2)
PATCH 1/1 watchdog: sama5d4_wdt: use platform_get_irq()
irq_of_parse_and_map() requires irq_dispose_mapping() on failure. Don't bother with it as platform_get_irq doesn't need it.
--- drivers/watchdog/sama5d4_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/sama5d4_wdt.c +2 -2
@@ -280,8 +280,8 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)return ret;if (wdt->need_irq) { - irq =irq_of_parse_and_map (dev->of_node,0 ); -if (!irq) { + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) {dev_warn (dev,"failed to get IRQ from DT\n" ); wdt->need_irq = false; }
Signature · 1 line
2.54.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Assigning the signed result of platform_get_irq() to an unsigned u32 variable causes the irq < 0 error check to always evaluate to false, breaking the driver's fallback mechanism.
- [Medium] Using platform_get_irq() instead of platform_get_irq_optional() for an optional IRQ causes spurious error messages to be logged.
Pre-existing issues:
- [High] The driver registers a shared interrupt handler (IRQF_SHARED) before setting the platform driver data, creating a race condition that can lead to a NULL pointer dereference. --
commit 7ff7f2de154616b7a42f6e5710f322b20ff6152e
Author: Rosen Penev <[email protected]>
watchdog: sama5d4_wdt: use platform_get_irq()
irq_of_parse_and_map() requires irq_dispose_mapping() on failure. Don't bother with it as platform_get_irq doesn't need it.
drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_probe(struct platform_device *pdev) · line 290
Quoted 12 lines
drivers/watchdog/sama5d4_wdt.c +2
-2@@ -286,8 +286,8 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)return ret;if (wdt->need_irq) { - irq =irq_of_parse_and_map (dev->of_node,0 ); -if (!irq) { + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) {
[Severity: High]
Since irq is declared as an unsigned u32 earlier in sama5d4_wdt_probe(), won't this irq < 0 check always evaluate to false?
platform_get_irq() returns a negative error code (like -ENXIO) on failure, which will be implicitly cast to a large positive integer. Instead of gracefully falling back by setting wdt->need_irq = false, won't the driver proceed to call devm_request_irq() with an invalid IRQ number and fail the probe?
[Severity: Medium]
Will this log spurious error messages when the IRQ is genuinely absent?
The driver treats the IRQ as optional and handles its absence gracefully. However, platform_get_irq() internally calls dev_err_probe(), printing a core-level error message to the kernel log when an IRQ is not found. Should this use platform_get_irq_optional() instead to avoid confusing user-visible error logs during boot?
drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_probe(struct platform_device *pdev) · line 287
Quoted 3 lines
drivers/watchdog/sama5d4_wdt.c +0
-0dev_warn (dev,"failed to get IRQ from DT\n" ); wdt->need_irq = false; }
[Severity: High]
This is a pre-existing issue, but does requesting a shared IRQ before setting the platform driver data create a race condition?
A few lines later in sama5d4_wdt_probe(), the driver requests the IRQ:
if (wdt->need_irq) {
ret = devm_request_irq(dev, irq, sama5d4_wdt_irq_handler,
IRQF_SHARED | IRQF_IRQPOLL |
IRQF_NO_SUSPEND, pdev->name, pdev);Because the IRQ is requested with IRQF_SHARED, another device sharing the line or a spurious interrupt could cause sama5d4_wdt_irq_handler() to execute immediately.
The interrupt handler calls platform_get_drvdata() and dereferences it:
drivers/watchdog/sama5d4_wdt.c:sama5d4_wdt_irq_handler() {
struct sama5d4_wdt *wdt = platform_get_drvdata(dev_id);
...
if (wdt->sam9x60_support)
...
}However, platform_set_drvdata(pdev, wdt) is only called at the very end of sama5d4_wdt_probe(). If the interrupt fires within this window, won't platform_get_drvdata() return NULL and cause a NULL pointer dereference?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Guenter Roeck
maintainerQuoted 35 lines · On 6/2/26 18:01, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Assigning the signed result ofplatform_get_irq()to an unsignedu32variable causes theirq < 0error check to always evaluate to false, breaking the driver's fallback mechanism.
- [Medium] Usingplatform_get_irq()instead ofplatform_get_irq_optional()for an optional IRQ causes spurious error messages to be logged.Pre-existing issues:
- [High] The driver registers a shared interrupt handler (IRQF_SHARED) before setting the platform driver data, creating a race condition that can lead to a NULL pointer dereference. --commit
7ff7f2de154616b7a42f6e5710f322b20ff6152e
Author: Rosen Penev <[email protected]>watchdog:
sama5d4_wdt: useplatform_get_irq()
irq_of_parse_and_map()requiresirq_dispose_mapping()on failure. Don't bother with it asplatform_get_irqdoesn't need it.drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_probe(struct platform_device *pdev) · line 290
Quoted 12 lines
drivers/watchdog/sama5d4_wdt.c +2
-2@@ -286,8 +286,8 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)return ret;if (wdt->need_irq) { - irq =irq_of_parse_and_map (dev->of_node,0 ); -if (!irq) { + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) {[Severity: High]
Since irq is declared as an unsigned u32 earlier insama5d4_wdt_probe(), won't this irq < 0 check always evaluate to false?
Quoted 6 lines
platform_get_irq()returns a negative error code (like-ENXIO) on failure, which will be implicitly cast to a large positive integer. Instead of gracefully falling back by settingwdt->need_irq= false, won't the driver proceed to calldevm_request_irq()with an invalid IRQ number and fail the probe?
Please fix the problems reported by Sashiko. That applies to all your patches.
Since it appears that you are fixing bugs based on issues reported by AI agents, I would kindly ask you to fix _all_ problems in the drivers you are modifying, not just a selected subset. In this specific case, the problem below is much more serious than the problem you are trying to fix. On top of that, the fix introduces two new problems while trying to fix one. That is not really helpful.
Thanks,
Guenter
Quoted 41 lines
[Severity: Medium]
Will this log spurious error messages when the IRQ is genuinely absent?The driver treats the IRQ as optional and handles its absence gracefully. However,
platform_get_irq()internally callsdev_err_probe(), printing a core-level error message to the kernel log when an IRQ is not found. Should this useplatform_get_irq_optional()instead to avoid confusing user-visible error logs during boot?drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_probe(struct platform_device *pdev) · line 287
Quoted 3 lines
drivers/watchdog/sama5d4_wdt.c +0
-0dev_warn (dev,"failed to get IRQ from DT\n" ); wdt->need_irq = false; }[Severity: High]
This is a pre-existing issue, but does requesting a shared IRQ before setting the platform driver data create a race condition?A few lines later in
sama5d4_wdt_probe(), the driver requests the IRQ:if (wdt->need_irq) { ret = devm_request_irq(dev, irq, sama5d4_wdt_irq_handler, IRQF_SHARED | IRQF_IRQPOLL | IRQF_NO_SUSPEND, pdev->name, pdev);Because the IRQ is requested with
IRQF_SHARED, another device sharing the line or a spurious interrupt could causesama5d4_wdt_irq_handler()to execute immediately.The interrupt handler calls
platform_get_drvdata()and dereferences it:drivers/watchdog/sama5d4_wdt.c:sama5d4_wdt_irq_handler() { struct sama5d4_wdt *wdt = platform_get_drvdata(dev_id); ... if (wdt->sam9x60_support) ... }However,
platform_set_drvdata(pdev, wdt)is only called at the very end ofsama5d4_wdt_probe(). If the interrupt fires within this window, won'tplatform_get_drvdata()return NULL and cause a NULL pointer dereference?
Quoted 37 lines · Guenter Roeck
Quoted 35 lines · On 6/2/26 18:01, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Assigning the signed result ofplatform_get_irq()to an unsignedu32variable causes theirq < 0error check to always evaluate to false, breaking the driver's fallback mechanism.
- [Medium] Usingplatform_get_irq()instead ofplatform_get_irq_optional()for an optional IRQ causes spurious error messages to be logged.Pre-existing issues:
- [High] The driver registers a shared interrupt handler (IRQF_SHARED) before setting the platform driver data, creating a race condition that can lead to a NULL pointer dereference. --commit
7ff7f2de154616b7a42f6e5710f322b20ff6152e
Author: Rosen Penev <[email protected]>watchdog:
sama5d4_wdt: useplatform_get_irq()
irq_of_parse_and_map()requiresirq_dispose_mapping()on failure. Don't bother with it asplatform_get_irqdoesn't need it.drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_probe(struct platform_device *pdev) · line 290
Quoted 12 lines
drivers/watchdog/sama5d4_wdt.c +2
-2@@ -286,8 +286,8 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)return ret;if (wdt->need_irq) { - irq =irq_of_parse_and_map (dev->of_node,0 ); -if (!irq) { + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) {[Severity: High]
Since irq is declared as an unsigned u32 earlier insama5d4_wdt_probe(), won't this irq < 0 check always evaluate to false?
Quoted 8 lines
Quoted 6 lines
platform_get_irq()returns a negative error code (like-ENXIO) on failure, which will be implicitly cast to a large positive integer. Instead of gracefully falling back by settingwdt->need_irq= false, won't the driver proceed to calldevm_request_irq()with an invalid IRQ number and fail the probe?Please fix the problems reported by Sashiko. That applies to all your patches.
Done for the reported ones. Sent as a series.
Quoted 2 lines
Since it appears that you are fixing bugs based on issues reported by AI agents,
Difficult to do given how late in the merge window this is. The other issue is every time I fix bugs reported by sashiko, it complains about new pre-existing ones. Cat and Mouse game at best.
Quoted 4 lines
I would kindly ask you to fix _all_ problems in the drivers you are modifying, not just a selected subset. In this specific case, the problem below is much more serious than the problem you are trying to fix. On top of that, the fix introduces two new problems while trying to fix one. That is not really helpful.
Agreed.
Quoted 46 lines
Thanks,
GuenterQuoted 41 lines
[Severity: Medium]
Will this log spurious error messages when the IRQ is genuinely absent?The driver treats the IRQ as optional and handles its absence gracefully. However,
platform_get_irq()internally callsdev_err_probe(), printing a core-level error message to the kernel log when an IRQ is not found. Should this useplatform_get_irq_optional()instead to avoid confusing user-visible error logs during boot?drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_probe(struct platform_device *pdev) · line 287
Quoted 3 lines
drivers/watchdog/sama5d4_wdt.c +0
-0dev_warn (dev,"failed to get IRQ from DT\n" ); wdt->need_irq = false; }[Severity: High]
This is a pre-existing issue, but does requesting a shared IRQ before setting the platform driver data create a race condition?A few lines later in
sama5d4_wdt_probe(), the driver requests the IRQ:if (
wdt->need_irq) {
ret = devm_request_irq(dev, irq,sama5d4_wdt_irq_handler,
IRQF_SHARED|IRQF_IRQPOLL|IRQF_NO_SUSPEND,pdev->name, pdev);Because the IRQ is requested with
IRQF_SHARED, another device sharing the line or a spurious interrupt could causesama5d4_wdt_irq_handler()to execute immediately.The interrupt handler calls
platform_get_drvdata()and dereferences it:drivers/watchdog/sama5d4_wdt.c:sama5d4_wdt_irq_handler() { struct sama5d4_wdt *wdt = platform_get_drvdata(dev_id); ... if (wdt->sam9x60_support) ... }However,
platform_set_drvdata(pdev, wdt)is only called at the very end ofsama5d4_wdt_probe(). If the interrupt fires within this window, won'tplatform_get_drvdata()return NULL and cause a NULL pointer dereference?
Guenter Roeck
maintainerQuoted 45 lines · Rosen Penev
Quoted 44 lines · Guenter Roeck
Quoted 41 lines · On 6/2/26 18:01, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Assigning the signed result ofplatform_get_irq()to an unsignedu32variable causes theirq < 0error check to always evaluate to false, breaking the driver's fallback mechanism.
- [Medium] Usingplatform_get_irq()instead ofplatform_get_irq_optional()for an optional IRQ causes spurious error messages to be logged.Pre-existing issues:
- [High] The driver registers a shared interrupt handler (IRQF_SHARED) before setting the platform driver data, creating a race condition that can lead to a NULL pointer dereference. --commit
7ff7f2de154616b7a42f6e5710f322b20ff6152e
Author: Rosen Penev <[email protected]>watchdog:
sama5d4_wdt: useplatform_get_irq()
irq_of_parse_and_map()requiresirq_dispose_mapping()on failure. Don't bother with it asplatform_get_irqdoesn't need it.drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_probe(struct platform_device *pdev) · line 290
Quoted 12 lines
drivers/watchdog/sama5d4_wdt.c +2
-2@@ -286,8 +286,8 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)return ret;if (wdt->need_irq) { - irq =irq_of_parse_and_map (dev->of_node,0 ); -if (!irq) { + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) {[Severity: High]
Since irq is declared as an unsigned u32 earlier insama5d4_wdt_probe(), won't this irq < 0 check always evaluate to false?
platform_get_irq()returns a negative error code (like-ENXIO) on failure, which will be implicitly cast to a large positive integer. Instead of gracefully falling back by settingwdt->need_irq= false, won't the driver proceed to calldevm_request_irq()with an invalid IRQ number and fail the probe?
Quoted 7 lines
Quoted 1 line
Please fix the problems reported by Sashiko. That applies to all your patches.
Done for the reported ones. Sent as a series.
Quoted 2 lines
Since it appears that you are fixing bugs based on issues reported by AI agents,
Difficult to do given how late in the merge window this is. The other issue is every time I fix bugs reported by sashiko, it complains about new pre-existing ones. Cat and Mouse game at best.
That can not be helped. Also, bug fixes do not depend on commit windows.
Guenter