Article View: linux.kernel.netdev
Article #12039[PATCH net-next] net: ethernet: adi: adin1110: Fix phy_device leak in probe_netdevs()
From: Xia Yan
Date: Fri, 06 Nov 2026 07:23
Date: Fri, 06 Nov 2026 07:23
59 lines
10975 bytes
10975 bytes
adin1110_probe_netdevs() probes each port with get_phy_device(), which
allocates a phy_device without registering it. The pointer's only use
is phydev_name() for the phy_connect() call, and phy_connect() attaches
the device the earlier bus scan registered, not the one allocated here.
port_priv->phydev is then overwritten with the phy_connect() result and
the allocated object is lost.
The devm cleanup action only disconnects the PHY that phy_connect()
attached, so nothing frees the lost object: one struct phy_device per
port leaks on every probe.
Keep the get_phy_device() result in a local variable and free it with
phy_device_free() after phy_connect() returns, success or not, as
mdiobus_scan() already does when phy_device_register() fails.
Found during a code review of the MDIO attach paths. get_phy_device()
only calls phy_device_create(), and phy_connect() can only return a
registered device.
Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
---
drivers/net/ethernet/adi/adin1110.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi/adin1110.c
index 53fac3d..fd769f1 100644
--- a/drivers/net/ethernet/adi/adin1110.c
+++ b/drivers/net/ethernet/adi/adin1110.c
@@ -1571,6 +1571,7 @@ static int adin1110_probe_netdevs(struct adin1110_priv *priv)
struct device *dev = &priv->spidev->dev;
struct adin1110_port_priv *port_priv;
struct net_device *netdev;
+ struct phy_device *phydev;
int ret;
int i;
@@ -1604,16 +1605,17 @@ static int adin1110_probe_netdevs(struct adin1110_priv *priv)
netdev->priv_flags |= IFF_UNICAST_FLT;
netdev->netns_immutable = true;
- port_priv->phydev = get_phy_device(priv->mii_bus, i + 1, false);
- if (IS_ERR(port_priv->phydev)) {
+ phydev = get_phy_device(priv->mii_bus, i + 1, false);
+ if (IS_ERR(phydev)) {
netdev_err(netdev, "Could not find PHY with device address: %d.\n", i);
- return PTR_ERR(port_priv->phydev);
+ return PTR_ERR(phydev);
}
port_priv->phydev = phy_connect(netdev,
- phydev_name(port_priv->phydev),
+ phydev_name(phydev),
adin1110_adjust_link,
PHY_INTERFACE_MODE_INTERNAL);
+ phy_device_free(phydev);
if (IS_ERR(port_priv->phydev)) {
netdev_err(netdev, "Could not connect PHY with device address: %d.\n", i);
return PTR_ERR(port_priv->phydev);
Technical Details
Message-ID:
<1793949783000.333861.5224091507677300156@cmss.chinamobile.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357808-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357808-linux-kernel-netdev=dewy.ru From: yanxia@cmss.chinamobile.com (Xia Yan) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next] net: ethernet: adi: adin1110: Fix phy_device leak in probe_netdevs() Date: Fri, 06 Nov 2026 15:23:03 +0800 Organization: Usenet Network Message-ID: <1793949783000.333861.5224091507677300156@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="3817669"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:OiQpCMXQWODbelLyvlaxlUAbJ7A= sha256:DHOd42Gasr5fpnZJeeRclfonf1ilz2RZcOZt1jA++Xc= sha1:LC/CHqbxmV5NsplnD/dlKUfdkvY= sha256:jEC6fr6vNaLH2VkLSqLIAgnscdoAO+Kc+YlVMlWXca4= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id ED9E011317D; Fri, 6 Nov 2026 10:24:03 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.851 X-Spam-Status: No, score=-2.851 tagged_above=-9999 required=6.31 tests=[DKIM_INVALID=0.1, DKIM_SIGNED=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key) reason="fail (body has been altered)" header.d=cmss.chinamobile.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fh0tsEq_c5To; Fri, 6 Nov 2026 10:24:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-357808-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 4D03311315B; Fri, 6 Nov 2026 10:23:52 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 2A793603036; Fri, 6 Nov 2026 07:23:32 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793949790; b=V+dCZYbLd4umbT861pQBfHnnzthBoNetGB3A75CSukSNC7sczd5c8eKAlP5yjb7KICqN dTytEYOzB+MdLlMXKGxcOFzslbTc6RV47voPDUeeymzBVpw4Oa379J/DzfNXhYpWqXvRQ kmJEeKDWTKSw2cxRPJCm027+KZGqn7uVVfw2MZK8YU9zm+Ho5BGUEa7dlo0VLiqltjQ5N hDzXeFCAnsMSr42V8OqMNz/XfriHNAplN3VROv7DcFIVNaxLQPd0FcgMbjOhgo28V5nFB pABTLxgSvgpGFaB15sLrPg4Ko3ZKYZSEzh38aamilyt95KWjQBwhyusLHEhw26uWCzw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793949790; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo: X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG: Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=pCfFm456CsVfjOH88KlSb93hqVwmD/ejTQ6cUioUW+4=; b=nUnxo0x5xsMBsJpRQo16kevhzPrZGvmEMfV49AUSRdB/LOGbLIm/8UMn3a7bMPwQdH35 vDpozaRqXUCMwHA0pJjdgQx8CZFuz15CMy5DlWv60QKn3lJfstFQmWTkxgV6Fze3spxAI lbELcZCa9OUFmA+bIxCEoma2KJG6rqOmo8ovSf3R7A8MmYopZ2Hknp94Bv50VDL9Fh7BW MfeCqMlSRVfT/MNv5xxPMEnuNQLIWmz+gLZ+3foSTnnNPh6u783gXGsTK0D8zYyPaauGh s4FWpBA6NXb4YPfZIwy8BPN4PFKKp9uMKFZM8o8UYtqtpVQm9pkGh4ocAy/rWi+Tpug== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=Z7rs94EX; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4524606A332; Fri, 6 Nov 2026 07:23:10 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=Z7rs94EX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.137 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793949789; b=iJ7xxJuKfy1kIALJw/OgFrMfp8lMOoJhvmjynq094DHXCvtPMMqqcVy3tfoQLONIj+31 8U8cmVFUBz7PvRKBkFtktowq4FBzLjc/hxkbcPSdvtHTUu/el2xmvlGnraX4tyER7DGi/ sd7SWeAu1vb5uFZyawBeGlygiOJerrQhe/tjug77fZL8bDRymM6XYc9jJX1w9neHFwE/y NIsgLP+7ri+E99qMbRjfJfkUZrmxfhAwx77bB7QnkRpa+PuU+F2BIoq7af2R9gdBFWOIn EMElrAujZ9Rhsfqk7wdKeTQh54y9Qui0YUxjNbFt/NKj1Ot4cwl5NjQFxIMFtsy+7eg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793949789; h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received: X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From: To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=pCfFm456CsVfjOH88KlSb93hqVwmD/ejTQ6cUioUW+4=; b=U9SXOth/bou1cg22LQkpKiIGhW1DRfXbFGUJb8spD01WXbT8hRAOzQzHyb/85U9WDISV AdrnckUYQhT749Hom8+YEjf3gYG7MSPX+Xg9D/9lP4k7CKRHFT9GyIFe5kH56auzFex0e jKgEja0tEjxW6RhntIOzhgfoTLylvkDS9bEh2fNGx2rCRb/gYHMc8mFx+ddHEPX+b+1d4 AWOltRQxMihso3zhLnpiMLbyOSOfOnphSwBKUuVtNdst3GIux6FGbgx6fDZ1w84iF9X9o HvrXt8KR+V7YHGET8ZcP/qbENUYCv/IleNqum65UIJxNpreHJROfSDILjkZ9nuvRNzw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=Z7rs94EX; arc=none smtp.remote-ip=111.22.67.137 X-Received: from cmccmta4.chinamobile.com (cmccmta4.chinamobile.com [111.22.67.137]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD812606A329; Fri, 6 Nov 2026 07:23:06 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CD812606A329 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmss.chinamobile.com; s=default; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=Z7rs94EXRPOwAmC+lPUo5h7O8utGpAcjvA5IKWWLg7WFiMGElSzpP9WTajzqY4n6K2frcs7tIwwy5 LKTk63IVt0v3jMp0bvvtlFJ9VUEODj23fIS9kNPJXCcHj2w8Ut6lrKFuGGPvMlwl3yZJqnNewXoki8 cQsQlEY1st3YyPQE= X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app04-12004 (RichMail) with SMTP id 2ee46aed80543bc-4df6d; Fri, 06 Nov 2026 15:23:04 +0800 (CST) X-RM-TRANSID: 2ee46aed80543bc-4df6d X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from [198.18.0.104] (unknown[223.108.79.97]) by rmsmtp-syy-appsvr03-12003 (RichMail) with SMTP id 2ee36aed805776c-169ad; Fri, 06 Nov 2026 15:23:04 +0800 (CST) X-RM-TRANSID: 2ee36aed805776c-169ad X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Eric Dumazet <edumazet@kernel.org>, David S. Miller <davem@davemloft.net>, Alexandru Tachici <alexandru.tachici@analog.com>, Ciprian Regus <ciprian.regus@analog.com>, linux-kernel@vger.kernel.org, yana06070@163.com X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list