* linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418: array index used before limits check ?
@ 2015-06-08 11:05 David Binderman
2015-06-08 13:10 ` Thomas Gleixner
0 siblings, 1 reply; 5+ messages in thread
From: David Binderman @ 2015-06-08 11:05 UTC (permalink / raw)
To: tglx, jason; +Cc: linux-kernel
Hello there,
[linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418]: (style) Array ind
ex 'k' is used before limits check.
if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
Suggest sanity check array index before use.
Regards
David Binderman
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418: array index used before limits check ?
2015-06-08 11:05 linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418: array index used before limits check ? David Binderman
@ 2015-06-08 13:10 ` Thomas Gleixner
2015-06-08 13:16 ` David Binderman
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2015-06-08 13:10 UTC (permalink / raw)
To: David Binderman; +Cc: jason, linux-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 350 bytes --]
On Mon, 8 Jun 2015, David Binderman wrote:
> Hello there,
>
> [linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418]: (style) Array ind
> ex 'k' is used before limits check.
>
> if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
>
> Suggest sanity check array index before use.
Which version of gcc is being stupid here?
Thanks,
tglx
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418: array index used before limits check ?
2015-06-08 13:10 ` Thomas Gleixner
@ 2015-06-08 13:16 ` David Binderman
2015-06-08 13:26 ` Thomas Gleixner
0 siblings, 1 reply; 5+ messages in thread
From: David Binderman @ 2015-06-08 13:16 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: jason, linux-kernel
Hello there Thomas,
----------------------------------------
>> [linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418]: (style) Array ind
>> ex 'k' is used before limits check.
>>
>> if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
>>
>> Suggest sanity check array index before use.
>
> Which version of gcc is being stupid here?
None of them.
The original "(style)" message is from a static analysis tool called cppcheck.
I can't think of a situation where, if an array index needs checking, then
it should be checked *after* use.
Regards
David Binderman
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418: array index used before limits check ?
2015-06-08 13:16 ` David Binderman
@ 2015-06-08 13:26 ` Thomas Gleixner
2015-06-08 16:40 ` David Binderman
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2015-06-08 13:26 UTC (permalink / raw)
To: David Binderman; +Cc: jason, linux-kernel
On Mon, 8 Jun 2015, David Binderman wrote:
> ----------------------------------------
> >> [linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418]: (style) Array ind
> >> ex 'k' is used before limits check.
> >>
> >> if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
> >>
> >> Suggest sanity check array index before use.
> >
> > Which version of gcc is being stupid here?
>
> None of them.
>
> The original "(style)" message is from a static analysis tool called cppcheck.
>
> I can't think of a situation where, if an array index needs checking, then
> it should be checked *after* use.
It does not check the array index. Read the complete code:
for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k);
if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
The array bound is INTC_IRQPIN_REG_NR and the check about which that
tool complains has nothing to do with array bounds. Completely valid
code.
Thanks,
tglx
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418: array index used before limits check ?
2015-06-08 13:26 ` Thomas Gleixner
@ 2015-06-08 16:40 ` David Binderman
0 siblings, 0 replies; 5+ messages in thread
From: David Binderman @ 2015-06-08 16:40 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: jason, linux-kernel
Hello there Thomas,
----------------------------------------
>> I can't think of a situation where, if an array index needs checking, then
>> it should be checked *after* use.
>
> It does not check the array index. Read the complete code:
>
> for (k = 0; k < INTC_IRQPIN_REG_NR; k++) {
> io[k] = platform_get_resource(pdev, IORESOURCE_MEM, k);
> if (!io[k] && k < INTC_IRQPIN_REG_NR_MANDATORY) {
>
> The array bound is INTC_IRQPIN_REG_NR and the check about which that
> tool complains has nothing to do with array bounds. Completely valid
> code.
After a deeper look at the code, agreed. False positive by the tool.
I also checked the rest of the /irqchip/ directory for other messages by
the tool and couldn't see anything else suspicious.
Regards
David Binderman
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-08 16:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-08 11:05 linux-4.1-rc7/drivers/irqchip/irq-renesas-intc-irqpin.c:418: array index used before limits check ? David Binderman
2015-06-08 13:10 ` Thomas Gleixner
2015-06-08 13:16 ` David Binderman
2015-06-08 13:26 ` Thomas Gleixner
2015-06-08 16:40 ` David Binderman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®