Subject: [PATCH] net: hns: Fix missing put_device() call in hns_mac_register_phy

From: Miaoqian Lin <[email-masked]>
Date: Mon, 10 Jan 2022 06:40:29 +0000

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 <[email-masked]>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 7edf8569514c..7364e05487c7 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -764,6 +764,7 @@ 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;
 	}
 
-- 
2.17.1