linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: "David S. Miller" <davem@davemloft.net>, Sam Creasey <sammy@sammy.net>
Cc: netdev@vger.kernel.org, linux-m68k@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH] net/sun3_82586: Kill array subscript above array bounds warning
Date: Wed, 17 Jul 2013 14:25:05 +0200	[thread overview]
Message-ID: <1374063905-4050-1-git-send-email-geert@linux-m68k.org> (raw)

drivers/net/ethernet/i825xx/sun3_82586.c: In function 'sun3_82586_timeout':
drivers/net/ethernet/i825xx/sun3_82586.c:993:89: warning: array subscript is above array bounds [-Warray-bounds]

Using the default NUM_XMIT_BUFFS = 1, there's only one transmit buffer.
Hence accessing the second buffer is an out-of-bounds access.
Print the command status of the first NOP buffer instead.

Fortunately this actually worked fine, as the layout of transmit and NOP
buffers is sufficiently similar.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
  - Untested due to lack of hardware
  - Note that the driver never compiled with the non-default NUM_XMIT_BUFFS > 1

 drivers/net/ethernet/i825xx/sun3_82586.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/i825xx/sun3_82586.c b/drivers/net/ethernet/i825xx/sun3_82586.c
index 353f57f6..d283d2e 100644
--- a/drivers/net/ethernet/i825xx/sun3_82586.c
+++ b/drivers/net/ethernet/i825xx/sun3_82586.c
@@ -990,7 +990,14 @@ static void sun3_82586_timeout(struct net_device *dev)
 	{
 #ifdef DEBUG
 		printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
-		printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
+		printk("%s: command-stats: %04x %04x\n", dev->name,
+		       swab16(p->xmit_cmds[0]->cmd_status),
+#if (NUM_XMIT_BUFFS > 1)
+		       swab16(p->xmit_cmds[1]->cmd_status)
+#else
+		       swab16(p->nop_cmds[0]->cmd_status)
+#endif
+		);
 		printk("%s: check, whether you set the right interrupt number!\n",dev->name);
 #endif
 		sun3_82586_close(dev);
-- 
1.7.9.5


             reply	other threads:[~2013-07-17 12:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 12:25 Geert Uytterhoeven [this message]
2013-07-18  1:22 ` [PATCH] net/sun3_82586: Kill array subscript above array bounds warning David Miller
2013-07-18  7:04   ` Geert Uytterhoeven

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=1374063905-4050-1-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sammy@sammy.net \
    /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).