[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221117090514.118296-1-tanghui20@huawei.com>
Date: Thu, 17 Nov 2022 17:05:14 +0800
From: Hui Tang <tanghui20@...wei.com>
To: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<mw@...ihalf.com>, <linux@...linux.org.uk>, <andrew@...n.ch>,
<pabeni@...hat.com>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<yusongping@...wei.com>
Subject: [PATCH net v2] net: mdio-ipq4019: fix possible invalid pointer dereference
priv->eth_ldo_rdy is saved the return value of devm_ioremap_resource(),
which !IS_ERR() should be used to check.
Fixes: 23a890d493e3 ("net: mdio: Add the reset function for IPQ MDIO driver")
Signed-off-by: Hui Tang <tanghui20@...wei.com>
---
v1 -> v2: set priv->eth_ldo_rdy NULL, if devm_ioremap_resource() failed
---
drivers/net/mdio/mdio-ipq4019.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c
index 4eba5a91075c..dfd1647eac36 100644
--- a/drivers/net/mdio/mdio-ipq4019.c
+++ b/drivers/net/mdio/mdio-ipq4019.c
@@ -231,8 +231,11 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)
/* The platform resource is provided on the chipset IPQ5018 */
/* This resource is optional */
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (res)
+ if (res) {
priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(priv->eth_ldo_rdy))
+ priv->eth_ldo_rdy = NULL;
+ }
bus->name = "ipq4019_mdio";
bus->read = ipq4019_mdio_read;
--
2.17.1
Powered by blists - more mailing lists