Patchwork [BUGFIX] net: ethernet: cpsw: fix erroneous condition in error check

login
register
mail settings
Submitter Lothar Waßmann
Date March 21, 2013, 12:20 p.m.
Message ID <1363868411-25318-1-git-send-email-LW@KARO-electronics.de>
Download mbox | patch
Permalink /patch/229654/
State Accepted
Delegated to: David Miller
Headers show

Comments

Lothar Waßmann - March 21, 2013, 12:20 p.m.
The error check in cpsw_probe_dt() has an '&&' where an '||' is
meant to be. This causes a NULL pointer dereference when incomplet DT
data is passed to the driver ('phy_id' property for cpsw_emac1
missing).


Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/net/ethernet/ti/cpsw.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
David Miller - March 21, 2013, 3:57 p.m.
From: Mugunthan V N <mugunthanvnm@ti.com>
Date: Thu, 21 Mar 2013 18:02:21 +0530

> On 3/21/2013 5:50 PM, Lothar Waßmann wrote:
>> The error check in cpsw_probe_dt() has an '&&' where an '||' is
>> meant to be. This causes a NULL pointer dereference when incomplet DT
>> data is passed to the driver ('phy_id' property for cpsw_emac1
>> missing).
>>
>>
>> Signed-off-by: Lothar Waßmann<LW@KARO-electronics.de>
> Acked-by: Mugunthan V N <mugunthanvnm@ti.com>

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

Patch

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 5ceaa4c3..7aebc0c 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1504,7 +1504,7 @@  static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		struct platform_device *mdio;
 
 		parp = of_get_property(slave_node, "phy_id", &lenp);
-		if ((parp == NULL) && (lenp != (sizeof(void *) * 2))) {
+		if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
 			pr_err("Missing slave[%d] phy_id property\n", i);
 			ret = -EINVAL;
 			goto error_ret;