diff mbox

[3.19.y-ckt,stable] Patch "net: dsa: Test array index before use" has been added to staging queue

Message ID 1438811293-32561-1-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa Aug. 5, 2015, 9:48 p.m. UTC
This is a note to let you know that I have just added a patch titled

    net: dsa: Test array index before use

to the linux-3.19.y-queue branch of the 3.19.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.19.y-queue

This patch is scheduled to be released in version 3.19.8-ckt5.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.19.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

From 106beb6d193d6079eff178ddd0fe12dd2ac4094d Mon Sep 17 00:00:00 2001
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Sat, 11 Jul 2015 18:02:10 -0700
Subject: net: dsa: Test array index before use

commit 8f5063e97f393d49611151d3cf7dcbeb41397f12 upstream.

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/dsa/dsa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
1.9.1
diff mbox

Patch

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index ed1bcee..43bc5c7 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -639,6 +639,8 @@  static int dsa_of_probe(struct platform_device *pdev)
 				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)
@@ -663,8 +665,6 @@  static int dsa_of_probe(struct platform_device *pdev)
 					goto out_free_chip;
 			}

-			if (port_index == DSA_MAX_PORTS)
-				break;
 		}
 	}