From: Roel Kluin <12o3l@tiscali.nl>
To: romieu@fr.zoreil.com
Cc: netdev@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] NET: r8169: fix past rtl_chip_info arraysize for unknown chipsets
Date: Thu, 17 Apr 2008 16:40:05 +0200 [thread overview]
Message-ID: <48076145.1080906@tiscali.nl> (raw)
i is unsigned, so, with an unknown chip, for (;i >= 0;) fails and i
just keeps decrementing, underflowing past ARRAY_SIZE(rtl_chip_info).
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 3acfeea..7d6be1b 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1702,21 +1702,19 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
/* Identify chip attached to board */
rtl8169_get_mac_version(tp, ioaddr);
-
rtl8169_print_mac_version(tp);
- for (i = ARRAY_SIZE(rtl_chip_info) - 1; i >= 0; i--) {
- if (tp->mac_version == rtl_chip_info[i].mac_version)
+ for (i = ARRAY_SIZE(rtl_chip_info) - 1;
+ tp->mac_version != rtl_chip_info[i].mac_version; i--) {
+ if (i == 0) {
+ /* Unknown chip: assume chipset 0: original RTL-8169 */
+ if (netif_msg_probe(tp)) {
+ dev_printk(KERN_DEBUG, &pdev->dev,
+ "unknown chip version, assuming %s\n",
+ rtl_chip_info[0].name);
+ }
break;
- }
- if (i < 0) {
- /* Unknown chip: assume array element #0, original RTL-8169 */
- if (netif_msg_probe(tp)) {
- dev_printk(KERN_DEBUG, &pdev->dev,
- "unknown chip version, assuming %s\n",
- rtl_chip_info[0].name);
}
- i++;
}
tp->chipset = i;
reply other threads:[~2008-04-17 14:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=48076145.1080906@tiscali.nl \
--to=12o3l@tiscali.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=romieu@fr.zoreil.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).