ARM: OMAP: Fix use of possibly uninitialized irq variable
PATCH 1/1 ARM: OMAP: Fix use of possibly uninitialized irq variable
The current control flow of IRQ number assignment to irq variable allows a request of IRQ of unspecified value,
generating a warning under Clang compilation with omap1_defconfig on linux-next:
arch/arm/mach-omap1/pm.c:656:11: warning: variable 'irq' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
else if (cpu_is_omap16xx())
^~~~~~~~~~~~~~~~~
./arch/arm/mach-omap1/include/mach/soc.h:123:30: note: expanded from macro 'cpu_is_omap16xx'
^~~~~~~~~~~~~arch/arm/mach-omap1/pm.c:658:18: note: uninitialized use occurs here
if (request_irq(irq, omap_wakeup_interrupt, 0, "peripheral wakeup",
^~~arch/arm/mach-omap1/pm.c:656:7: note: remove the 'if' if its condition is always true
else if (cpu_is_omap16xx())
^~~~~~~~~~~~~~~~~~~~~~
arch/arm/mach-omap1/pm.c:611:9: note: initialize the variable 'irq' to silence this warning
int irq;
^
= 01 warning generated.
The patch provides a default value to the irq variable along with a validity check.
--- arch/arm/mach-omap1/pm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm/mach-omap1/pm.c +7 -3
@@ -655,9 +655,13 @@ static int __init omap_pm_init(void) irq =INT_7XX_WAKE_UP_REQ ; else if (cpu_is_omap16xx()) irq =INT_1610_WAKE_UP_REQ ; -if (request_irq (irq, omap_wakeup_interrupt,0 ,"peripheral wakeup" , -NULL )) -pr_err ("Failed to request irq %d (peripheral wakeup)\n" , irq); + else + irq =-1 ; + +if (irq >=0 ) { +if (request_irq (irq, omap_wakeup_interrupt,0 ,"peripheral wakeup" ,NULL )) +pr_err ("Failed to request irq %d (peripheral wakeup)\n" , irq); + }/* Program new power ramp-up time * (0 for most boards since we don't lower voltage when in deep sleep)
Signature · 7 lines
2.26.3 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 20 lines · Maciej Falkowski
The current control flow of IRQ number assignment to
irqvariable allows a request of IRQ of unspecified value,
generating a warning under Clang compilation withomap1_defconfigon linux-next:
arch/arm/mach-omap1/pm.c:656:11: warning: variable 'irq' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]else if (cpu_is_omap16xx()) ^~~~~~~~~~~~~~~~~ ./arch/arm/mach-omap1/include/mach/soc.h:123:30: note: expanded from macro 'cpu_is_omap16xx' ^~~~~~~~~~~~~
arch/arm/mach-omap1/pm.c:658:18: note: uninitialized use occurs here
if (request_irq(irq,omap_wakeup_interrupt, 0, "peripheral wakeup",
^~~arch/arm/mach-omap1/pm.c:656:7: note: remove the 'if' if its condition is always trueelse if (cpu_is_omap16xx()) ^~~~~~~~~~~~~~~~~~~~~~ arch/arm/mach-omap1/pm.c:611:9: note: initialize the variable 'irq' to silence this warning int irq; ^ = 0
Quoted 5 lines
1 warning generated.
The patch provides a default value to the
irqvariable along with a validity check.
Might be worth a fixes tag:
Quoted 2 lines
Quoted 28 lines
--- arch/arm/mach-omap1/pm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)arch/arm/mach-omap1/pm.c +7
-3@@ -655,9 +655,13 @@ static int __init omap_pm_init(void) irq =INT_7XX_WAKE_UP_REQ ; else if (cpu_is_omap16xx()) irq =INT_1610_WAKE_UP_REQ ; -if (request_irq (irq, omap_wakeup_interrupt,0 ,"peripheral wakeup" , -NULL )) -pr_err ("Failed to request irq %d (peripheral wakeup)\n" , irq); + else + irq =-1 ; + +if (irq >=0 ) { +if (request_irq (irq, omap_wakeup_interrupt,0 ,"peripheral wakeup" ,NULL )) +pr_err ("Failed to request irq %d (peripheral wakeup)\n" , irq); + }/* Program new power ramp-up time * (0 for most boards since we don't lower voltage when in deep sleep) Signature · 1 line
2.26.3
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 15 lines · Maciej Falkowski
The current control flow of IRQ number assignment to
irqvariable allows a request of IRQ of unspecified value,
generating a warning under Clang compilation withomap1_defconfigon linux-next:
arch/arm/mach-omap1/pm.c:656:11: warning: variable 'irq' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]else if (cpu_is_omap16xx()) ^~~~~~~~~~~~~~~~~ ./arch/arm/mach-omap1/include/mach/soc.h:123:30: note: expanded from macro 'cpu_is_omap16xx' ^~~~~~~~~~~~~
arch/arm/mach-omap1/pm.c:658:18: note: uninitialized use occurs here
if (request_irq(irq,omap_wakeup_interrupt, 0, "peripheral wakeup",
^~~arch/arm/mach-omap1/pm.c:656:7: note: remove the 'if' if its condition is always true
Quoted 7 lines
else if (cpu_is_omap16xx()) ^~~~~~~~~~~~~~~~~~~~~~ arch/arm/mach-omap1/pm.c:611:9: note: initialize the variable 'irq' to silence this warning int irq; ^ = 01 warning generated.
Ooh, yeah if cpu_is_omap15xx() then irq is unused uninitialized; I don't see any INT_1610_WAKE_UP_REQ-equlivalent for INT_15XX_WAKE_UP_REQ.
Ok, LGTM.
I agree with Nathan on the Fixes tag.
Quoted 32 lines
The patch provides a default value to the
irqvariable along with a validity check.Signed-off-by Maciej Falkowski <[email protected]>--- arch/arm/mach-omap1/pm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)arch/arm/mach-omap1/pm.c +7
-4@@ -655,9 +655,13 @@ static int __init omap_pm_init(void) irq =INT_7XX_WAKE_UP_REQ ; else if (cpu_is_omap16xx()) irq =INT_1610_WAKE_UP_REQ ; -if (request_irq (irq, omap_wakeup_interrupt,0 ,"peripheral wakeup" , -NULL )) -pr_err ("Failed to request irq %d (peripheral wakeup)\n" , irq); + else + irq =-1 ; + +if (irq >=0 ) { +if (request_irq (irq, omap_wakeup_interrupt,0 ,"peripheral wakeup" ,NULL )) +pr_err ("Failed to request irq %d (peripheral wakeup)\n" , irq); + }/* Program new power ramp-up time * (0 for most boards since we don't lower voltage when in deep sleep) --
Signature · 7 lines
Thanks, ~Nick Desaulniers _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Tony Lindgren
reviewerQuoted 14 lines · Maciej Falkowski
The current control flow of IRQ number assignment to
irqvariable allows a request of IRQ of unspecified value,
generating a warning under Clang compilation withomap1_defconfigon linux-next:
arch/arm/mach-omap1/pm.c:656:11: warning: variable 'irq' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]else if (cpu_is_omap16xx()) ^~~~~~~~~~~~~~~~~ ./arch/arm/mach-omap1/include/mach/soc.h:123:30: note: expanded from macro 'cpu_is_omap16xx' ^~~~~~~~~~~~~
arch/arm/mach-omap1/pm.c:658:18: note: uninitialized use occurs here
if (request_irq(irq,omap_wakeup_interrupt, 0, "peripheral wakeup",
^~~arch/arm/mach-omap1/pm.c:656:7: note: remove the 'if' if its condition is always true
Quoted 6 lines
else if (cpu_is_omap16xx())
^~~~~~~~~~~~~~~~~~~~~~
arch/arm/mach-omap1/pm.c:611:9: note: initialize the variable 'irq' to silence this warning
int irq;
^
= 0Thanks applying into fixes.
Tony