netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Jan Kasprzak <kas@fi.muni.cz>
Cc: Ameen Ali <ameenali023@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] cosa.c : Array index 'i' is used before limits check.
Date: Mon, 02 Mar 2015 17:16:15 +0300	[thread overview]
Message-ID: <54F470AF.6050401@cogentembedded.com> (raw)
In-Reply-To: <20150302130652.GX19534@fi.muni.cz>

Hello.

On 3/2/2015 4:06 PM, Jan Kasprzak wrote:

> : >avoid out-of-bounds-read by checking count before indexing.
> :
> : >Signed-off-by: Ameen Ali <Ameenali023@gmail.com>
> : >---
> : >  drivers/net/wan/cosa.c | 2 +-
> : >  1 file changed, 1 insertion(+), 1 deletion(-)
> :
> : >diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
> : >index 83c39e2..5252e21 100644
> : >--- a/drivers/net/wan/cosa.c
> : >+++ b/drivers/net/wan/cosa.c
> : >@@ -376,7 +376,7 @@ static int __init cosa_init(void)
> : >  	}
> : >  	for (i=0; i<MAX_CARDS; i++)
> : >  		cosa_cards[i].num = -1;
> : >-	for (i=0; io[i] != 0 && i < MAX_CARDS; i++)
> : >+	for (i=0; (i < MAX_CARDS) && (io[i] != 0) ; i++)

> :    Parens you've added aren't necessary.

> 	Yes, but I am OK with both variants.

    Anyway, space before ; should be removed (just noticed).

> :    I suggest to add spaces after and before = in the first expression.

> 	In that case, also the upper for() cycle should be modified
> to match this. I don't think this is necessary.

    As long as it doesn't cause complaints from scripts/checkpatch.pl...

> -Yenya

WBR, Sergei

      reply	other threads:[~2015-03-02 14:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24 19:52 [PATCH 2/2] cosa.c : Array index 'i' is used before limits check Ameen Ali
2015-02-24 19:57 ` Sergei Shtylyov
2015-03-02 13:06   ` Jan Kasprzak
2015-03-02 14:16     ` Sergei Shtylyov [this message]

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=54F470AF.6050401@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=ameenali023@gmail.com \
    --cc=kas@fi.muni.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).