Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1488657 > unrolled thread

[PATCH net-next] net: ethernet: mediatek: get out of potential invalid pointer access

Started by<sean.wang@mediatek.com>
First post2016-09-22 10:50 +0200
Last post2016-09-22 14:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH net-next] net: ethernet: mediatek: get out of potential invalid pointer access <sean.wang@mediatek.com> - 2016-09-22 10:50 +0200
    Re: [PATCH net-next] net: ethernet: mediatek: get out of potential  invalid pointer access David Miller <davem@davemloft.net> - 2016-09-22 14:30 +0200

#1488657 — [PATCH net-next] net: ethernet: mediatek: get out of potential invalid pointer access

From<sean.wang@mediatek.com>
Date2016-09-22 10:50 +0200
Subject[PATCH net-next] net: ethernet: mediatek: get out of potential invalid pointer access
Message-ID<sk7RE-42c-31@gated-at.bofh.it>
From: Sean Wang <sean.wang@mediatek.com>

Potential dangerous invalid pointer might be accessed if
the error happens when couple phy_device to net_device so
cleanup the error path.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index a65801a..3d7e0cb 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -296,7 +296,9 @@ static int mtk_phy_connect(struct net_device *dev)
 	regmap_write(eth->ethsys, ETHSYS_SYSCFG0, val);
 
 	/* couple phydev to net_device */
-	mtk_phy_connect_node(eth, mac, np);
+	if (mtk_phy_connect_node(eth, mac, np))
+		goto err_phy;
+
 	dev->phydev->autoneg = AUTONEG_ENABLE;
 	dev->phydev->speed = 0;
 	dev->phydev->duplex = 0;
@@ -317,7 +319,7 @@ static int mtk_phy_connect(struct net_device *dev)
 
 err_phy:
 	of_node_put(np);
-	dev_err(eth->dev, "invalid phy_mode\n");
+	dev_err(eth->dev, "%s: invalid phy\n", __func__);
 	return -EINVAL;
 }
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1488837 — Re: [PATCH net-next] net: ethernet: mediatek: get out of potential invalid pointer access

FromDavid Miller <davem@davemloft.net>
Date2016-09-22 14:30 +0200
SubjectRe: [PATCH net-next] net: ethernet: mediatek: get out of potential invalid pointer access
Message-ID<skbiy-6i0-11@gated-at.bofh.it>
In reply to#1488657
From: <sean.wang@mediatek.com>
Date: Thu, 22 Sep 2016 16:44:16 +0800

> From: Sean Wang <sean.wang@mediatek.com>
> 
> Potential dangerous invalid pointer might be accessed if
> the error happens when couple phy_device to net_device so
> cleanup the error path.
> 
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>

Applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web