From: Miaoqian Lin <linmq006@gmail.com>
To: kuba@kernel.org
Cc: davem@davemloft.net, linmq006@gmail.com,
linux-kernel@vger.kernel.org, lipeng321@huawei.com,
liuyonglong@huawei.com, mbrugger@suse.com,
netdev@vger.kernel.org, salil.mehta@huawei.com,
shenyang39@huawei.com, yisen.zhuang@huawei.com
Subject: [PATCH v2] net: hns: Fix missing put_device() call in hns_mac_register_phy
Date: Wed, 12 Jan 2022 10:39:19 +0000 [thread overview]
Message-ID: <20220112103919.28894-1-linmq006@gmail.com> (raw)
In-Reply-To: <20220111203333.507ec4f5@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
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@gmail.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
next prev parent reply other threads:[~2022-01-12 10:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 6:40 [PATCH] net: hns: Fix missing put_device() call in hns_mac_register_phy Miaoqian Lin
2022-01-12 4:33 ` Jakub Kicinski
2022-01-12 10:39 ` Miaoqian Lin [this message]
2022-01-12 13:46 ` [PATCH v2] " Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220112103919.28894-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lipeng321@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=mbrugger@suse.com \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=shenyang39@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).