lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1354542569-6165-2-git-send-email-jlu@pengutronix.de>
Date:	Mon,  3 Dec 2012 14:49:28 +0100
From:	Jan Luebbe <jlu@...gutronix.de>
To:	netdev@...r.kernel.org
Cc:	"David S. Miller" <davem@...emloft.net>,
	Mugunthan V N <mugunthanvnm@...com>,
	Vaibhav Hiremath <hvaibhav@...com>,
	linux-arm-kernel@...ts.infradead.org, linux-omap@...r.kernel.org,
	Jan Luebbe <jlu@...gutronix.de>
Subject: [PATCH 2/3] net: cpsw: verify correct number of slaves in DT

Check that the number of available slaves passed from DT matches the
value of the "slaves" property in the cpsw node. Otherwise, priv->slaves
would be the wrong size.

Signed-off-by: Jan Luebbe <jlu@...gutronix.de>
---
 drivers/net/ethernet/ti/cpsw.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index c0e676a..8de3e92 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -832,6 +832,16 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		const char *phy_id = NULL;
 		const void *mac_addr = NULL;
 
+		if (!of_device_is_available(slave_node))
+			continue;
+
+		if (i >= data->slaves) {
+			dev_err(&pdev->dev, "Too many slaves in the DT (> %d).\n",
+				data->slaves);
+			ret = -EINVAL;
+			goto error_ret;
+		}
+
 		if (of_property_read_string(slave_node, "phy_id", &phy_id)) {
 			dev_err(&pdev->dev, "Missing slave[%d] phy_id property.\n", i);
 			ret = -EINVAL;
@@ -861,6 +871,13 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		i++;
 	}
 
+	if (i < data->slaves) {
+		dev_err(&pdev->dev, "Not enough slaves in the DT (< %d).\n",
+			data->slaves);
+		ret = -EINVAL;
+		goto error_ret;
+	}
+
 	/*
 	 * Populate all the child nodes here...
 	 */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ