From: David Miller <davem@davemloft.net>
To: arushisinghal19971997@gmail.com
Cc: jdmason@kudzu.us, jakub.kicinski@netronome.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
oss-drivers@netronome.com, outreachy-kernel@googlegroups.com
Subject: Re: [PATCH v2] net: ethernet: Drop unnecessary continue
Date: Wed, 07 Mar 2018 10:39:01 -0500 (EST) [thread overview]
Message-ID: <20180307.103901.1771176275743006915.davem@davemloft.net> (raw)
In-Reply-To: <20180303161456.GA20194@seema-Inspiron-15-3567>
From: Arushi Singhal <arushisinghal19971997@gmail.com>
Date: Sat, 3 Mar 2018 21:44:56 +0530
> Continue at the bottom of a loop are removed.
> Issue found using drop_continue.cocci Coccinelle script.
>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> ---
> Changes in v2:
> - Braces is dropped from if with single statement.
Sorry there is no way I am applying this.
Just blindly removing continue statements that some static checker
or compiler warning mentions is completely unacceptable.
Actually _LOOK_ at this code:
> if(cards[i].vendor_id) {
> for(j=0;j<3;j++)
> - if(inb(ioaddr+cards[i].addr_offset+j) != cards[i].vendor_id[j]) {
> + if(inb(ioaddr+cards[i].addr_offset+j) != cards[i].vendor_id[j])
> release_region(ioaddr, cards[i].total_size);
> - continue;
> - }
> }
The extraneous continue statement is the _least_ of the problems here.
This code, if the if() statement triggers, will release the ioaddr
region and then _CONTINUE_ the for(j) loop, and try to access the
registers using the same 'ioaddr' again.
That's actually a _REAL_ bug, and you're making it seem like
the behavior is intentional by editing it like this.
And the bug probably exists because this entire sequence has
misaligned closing curly braces. It makes it look like
the continue is for the outer loop, which would be fine.
But it's not. It's for the inner loop, and this causes the "use
ioaddr after releasing it" bug.
Please do not submit patches like this one, it makes for a lot of
wasted auditing and review for people. The onus is on you to read
and understand the code you are editing before submitting your
changes.
Thank you.
next prev parent reply other threads:[~2018-03-07 15:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-03 16:14 [PATCH v2] net: ethernet: Drop unnecessary continue Arushi Singhal
2018-03-05 1:57 ` Jakub Kicinski
2018-03-07 15:39 ` David Miller [this message]
[not found] ` <CA+XqjF8_axeTnahPmokxmDnm4NmWo8QWSEmLejN4fO1nAiDaBA@mail.gmail.com>
2018-03-07 17:01 ` David Miller
2018-03-07 19:41 ` [Outreachy kernel] " Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180307.103901.1771176275743006915.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=arushisinghal19971997@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=jdmason@kudzu.us \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).