[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220112103919.28894-1-linmq006@gmail.com>
Date: Wed, 12 Jan 2022 10:39:19 +0000
From: Miaoqian Lin <linmq006@...il.com>
To: kuba@...nel.org
Cc: davem@...emloft.net, linmq006@...il.com,
linux-kernel@...r.kernel.org, lipeng321@...wei.com,
liuyonglong@...wei.com, mbrugger@...e.com, netdev@...r.kernel.org,
salil.mehta@...wei.com, shenyang39@...wei.com,
yisen.zhuang@...wei.com
Subject: [PATCH v2] net: hns: Fix missing put_device() call in hns_mac_register_phy
We need to drop the reference taken by hns_dsaf_find_platform_device
Missing put_device() may cause refcount leak.
Fixes: 804ffe5c6197 ("net: hns: support deferred probe when no mdio")
Signed-off-by: Miaoqian Lin <linmq006@...il.com>
---
Changes in v2:
- add put_device when hns_mac_register_phydev fails.
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 7edf8569514c..cba9d92e057e 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -764,13 +764,16 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
dev_err(mac_cb->dev,
"mac%d mdio is NULL, dsaf will probe again later\n",
mac_cb->mac_id);
+ put_device(&pdev->dev);
return -EPROBE_DEFER;
}
rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
- if (!rc)
+ if (!rc) {
dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
mac_cb->mac_id, addr);
+ put_device(&pdev->dev);
+ }
return rc;
}
--
2.17.1
Powered by blists - more mailing lists