netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fealnx: Write outside array bounds
@ 2009-07-24 11:49 Roel Kluin
  2009-07-25  9:55 ` Ilpo Järvinen
  0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2009-07-24 11:49 UTC (permalink / raw)
  To: David S. Miller, netdev, Andrew Morton

phy_idx is checked to be < 4, but np->phys[] is 2 elements long

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Or should the number of elements be increased?

diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 48385c4..100badd 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -584,7 +584,7 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
 	if (np->flags == HAS_MII_XCVR) {
 		int phy, phy_idx = 0;
 
-		for (phy = 1; phy < 32 && phy_idx < 4; phy++) {
+		for (phy = 1; phy < 32 && phy_idx < 2; phy++) {
 			int mii_status = mdio_read(dev, phy, 1);
 
 			if (mii_status != 0xffff && mii_status != 0x0000) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fealnx: Write outside array bounds
  2009-07-24 11:49 [PATCH] fealnx: Write outside array bounds Roel Kluin
@ 2009-07-25  9:55 ` Ilpo Järvinen
  2009-07-25 17:41   ` Roel Kluin
  0 siblings, 1 reply; 4+ messages in thread
From: Ilpo Järvinen @ 2009-07-25  9:55 UTC (permalink / raw)
  To: Roel Kluin; +Cc: David S. Miller, netdev, Andrew Morton

On Fri, 24 Jul 2009, Roel Kluin wrote:

> phy_idx is checked to be < 4, but np->phys[] is 2 elements long
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Or should the number of elements be increased?
> 
> diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
> index 48385c4..100badd 100644
> --- a/drivers/net/fealnx.c
> +++ b/drivers/net/fealnx.c
> @@ -584,7 +584,7 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
>  	if (np->flags == HAS_MII_XCVR) {
>  		int phy, phy_idx = 0;
>  
> -		for (phy = 1; phy < 32 && phy_idx < 4; phy++) {
> +		for (phy = 1; phy < 32 && phy_idx < 2; phy++) {
>  			int mii_status = mdio_read(dev, phy, 1);
>  
>  			if (mii_status != 0xffff && mii_status != 0x0000) {

In either of the case, one should use ARRAY_SIZE(np->phys) instead of the 
number.


-- 
 i.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fealnx: Write outside array bounds
  2009-07-25  9:55 ` Ilpo Järvinen
@ 2009-07-25 17:41   ` Roel Kluin
  2009-07-27  2:01     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2009-07-25 17:41 UTC (permalink / raw)
  To: Ilpo Järvinen; +Cc: David S. Miller, netdev, Andrew Morton

phy_idx is checked to be < 4, but np->phys[] is 2 elements long

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---

>> Or should the number of elements be increased?

>> -		for (phy = 1; phy < 32 && phy_idx < 4; phy++) {
>> +		for (phy = 1; phy < 32 && phy_idx < 2; phy++) {

> In either of the case, one should use ARRAY_SIZE(np->phys) instead of the 
> number.

Ah, yes.

diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 48385c4..160655d 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -584,7 +584,8 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
 	if (np->flags == HAS_MII_XCVR) {
 		int phy, phy_idx = 0;
 
-		for (phy = 1; phy < 32 && phy_idx < 4; phy++) {
+		for (phy = 1; phy < 32 && phy_idx < ARRAY_SIZE(np->phys);
+			       phy++) {
 			int mii_status = mdio_read(dev, phy, 1);
 
 			if (mii_status != 0xffff && mii_status != 0x0000) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fealnx: Write outside array bounds
  2009-07-25 17:41   ` Roel Kluin
@ 2009-07-27  2:01     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-07-27  2:01 UTC (permalink / raw)
  To: roel.kluin; +Cc: ilpo.jarvinen, netdev, akpm

From: Roel Kluin <roel.kluin@gmail.com>
Date: Sat, 25 Jul 2009 19:41:12 +0200

> phy_idx is checked to be < 4, but np->phys[] is 2 elements long
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-27  2:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-24 11:49 [PATCH] fealnx: Write outside array bounds Roel Kluin
2009-07-25  9:55 ` Ilpo Järvinen
2009-07-25 17:41   ` Roel Kluin
2009-07-27  2:01     ` David Miller

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).