From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, andrew@lunn.ch, linux@roeck-us.net,
dan.carpenter@oracle.com, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net 1/2] net: dsa: Test array index before use
Date: Sat, 11 Jul 2015 18:02:10 -0700 [thread overview]
Message-ID: <1436662931-8982-2-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1436662931-8982-1-git-send-email-f.fainelli@gmail.com>
port_index is used an index into an array, and this information comes
from Device Tree, make sure that port_index is not equal to the array
size before using it. Move the check against port_index earlier in the
loop.
Fixes: 5e95329b701c: ("dsa: add device tree bindings to register DSA switches")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
net/dsa/dsa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 392e29a0227d..52beeb8829dc 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -642,6 +642,8 @@ static int dsa_of_probe(struct device *dev)
continue;
port_index = be32_to_cpup(port_reg);
+ if (port_index >= DSA_MAX_PORTS)
+ break;
port_name = of_get_property(port, "label", NULL);
if (!port_name)
@@ -666,8 +668,6 @@ static int dsa_of_probe(struct device *dev)
goto out_free_chip;
}
- if (port_index == DSA_MAX_PORTS)
- break;
}
}
--
2.1.4
next prev parent reply other threads:[~2015-07-12 1:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-12 1:02 [PATCH net 0/2] net: dsa: OF parsing fixes Florian Fainelli
2015-07-12 1:02 ` Florian Fainelli [this message]
2015-07-12 1:02 ` [PATCH net 2/2] net: dsa: Fix off-by-one in switch address parsing Florian Fainelli
2015-07-12 6:25 ` [PATCH net 0/2] net: dsa: OF parsing fixes David Miller
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=1436662931-8982-2-git-send-email-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=linux@roeck-us.net \
--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).