netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: mdio-ipq4019: fix possible invalid pointer dereference
@ 2022-11-17  9:05 Hui Tang
  2022-11-17 13:57 ` Andrew Lunn
  0 siblings, 1 reply; 7+ messages in thread
From: Hui Tang @ 2022-11-17  9:05 UTC (permalink / raw)
  To: davem, edumazet, kuba, mw, linux, andrew, pabeni
  Cc: netdev, linux-kernel, yusongping

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@huawei.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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-23  1:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-17  9:05 [PATCH net v2] net: mdio-ipq4019: fix possible invalid pointer dereference Hui Tang
2022-11-17 13:57 ` Andrew Lunn
2022-11-18  7:21   ` Hui Tang
2022-11-18 13:44     ` Andrew Lunn
2022-11-19  5:41       ` Hui Tang
2022-11-21 14:36         ` Andrew Lunn
2022-11-23  1:10           ` Hui Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).