Skip to contentSkip to conversation

clocksource: ep93xx: fix error handling during probe

PATCH Applied Arnd Bergmann 3 participants 3 messages Dec 12, 2023 – Jan 18, 2024 Clocksource, clockevent drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: ep93xx: fix error handling during probe

From: Arnd Bergmann <[email protected]>

When the interrupt property fails to be parsed, ep93xx_timer_of_init() return code ends up uninitialized:

drivers/clocksource/timer-ep93xx.c:160:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

        if (irq < 0) {
            ^~~~~~~
drivers/clocksource/timer-ep93xx.c:188:9: note: uninitialized use occurs here
        return ret;
               ^~~
drivers/clocksource/timer-ep93xx.c:160:2: note: remove the 'if' if its condition is always false
        if (irq < 0) {
        ^~~~~~~~~~~~~~

Simplify this portion to use the normal construct of just checking whether a valid interrupt was returned. Note that irq_of_parse_and_map() never returns a negative value and no other callers check for that either.

Fixes c28ca80ba3b5 ("clocksource: ep93xx: Add driver for Cirrus Logic EP93xx")
---
 drivers/clocksource/timer-ep93xx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clocksource/timer-ep93xx.c +2 -3
index bc0ca6e12334..6981ff3ac8a9 100644
@@ -155,9 +155,8 @@ static int __init ep93xx_timer_of_init(struct device_node *np)
 	ep93xx_tcu = tcu;
 
 	irq = irq_of_parse_and_map(np, 0);
-	if (irq == 0)
-		irq = -EINVAL;
-	if (irq < 0) {
+	if (!irq) {
+		ret = -EINVAL;
 		pr_err("EP93XX Timer Can't parse IRQ %d", irq);
 		goto out_free;
 	}
Signature · 1 line
2.39.2
#1 lore raw
Quoted 15 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When the interrupt property fails to be parsed, ep93xx_timer_of_init() return code ends up uninitialized:

drivers/clocksource/timer-ep93xx.c:160:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

         if (irq < 0) {
             ^~~~~~~
drivers/clocksource/timer-ep93xx.c:188:9: note: uninitialized use occurs here
         return ret;
                ^~~
drivers/clocksource/timer-ep93xx.c:160:2: note: remove the 'if' if its condition is always false
         if (irq < 0) {
         ^~~~~~~~~~~~~~
Quoted 7 lines

Simplify this portion to use the normal construct of just checking whether a valid interrupt was returned. Note that irq_of_parse_and_map() never returns a negative value and no other callers check for that either.

Fixes c28ca80ba3b5 ("clocksource: ep93xx: Add driver for Cirrus Logic EP93xx")

---

Applied, thanks

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
merge bot Applied
#2 lore raw

[tip: timers/core] clocksource/drivers/ep93xx: Fix error handling during probe

In reply to Arnd Bergmann
The following commit has been merged into the timers/core branch of tip:

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     c0c4579d79d0df841e825c68df450909a0032faf
Gitweb:        https://git.kernel.org/tip/c0c4579d79d0df841e825c68df450909a0032faf
Author:        Arnd Bergmann <[email protected]>
AuthorDate:    Tue, 12 Dec 2023 22:46:07 +01:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Wed, 27 Dec 2023 15:37:11 +01:00

clocksource/drivers/ep93xx: Fix error handling during probe

When the interrupt property fails to be parsed, ep93xx_timer_of_init() return code ends up uninitialized:

drivers/clocksource/timer-ep93xx.c:160:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

        if (irq < 0) {
            ^~~~~~~
drivers/clocksource/timer-ep93xx.c:188:9: note: uninitialized use occurs here
        return ret;
               ^~~
drivers/clocksource/timer-ep93xx.c:160:2: note: remove the 'if' if its condition is always false
        if (irq < 0) {
        ^~~~~~~~~~~~~~

Simplify this portion to use the normal construct of just checking whether a valid interrupt was returned. Note that irq_of_parse_and_map() never returns a negative value and no other callers check for that either.

Fixes c28ca80ba3b5 ("clocksource: ep93xx: Add driver for Cirrus Logic EP93xx")
---
 drivers/clocksource/timer-ep93xx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clocksource/timer-ep93xx.c +2 -3
index bc0ca6e..6981ff3 100644
@@ -155,9 +155,8 @@ static int __init ep93xx_timer_of_init(struct device_node *np)
 	ep93xx_tcu = tcu;
 
 	irq = irq_of_parse_and_map(np, 0);
-	if (irq == 0)
-		irq = -EINVAL;
-	if (irq < 0) {
+	if (!irq) {
+		ret = -EINVAL;
 		pr_err("EP93XX Timer Can't parse IRQ %d", irq);
 		goto out_free;
 	}