From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796093194; b=s7xyWuQkRcd9HprbqIZFsrju6z0VlLERJ0BUvp8jf8vwGmnTBcmyCIRz1atbQYkbMSfy QtolpQEQXmwlmbDgDVvuAkgM/QDaKXHV5DAn2RGD6Te0MSKZdkBM2B1B18Mbd5xWBThkB MIobX1Dz4jqQ48drEFdOjH8mazTs9CRxqtHkVqiZnzIsykjdkEBe7usus/ZVYa34TRlOY wo8Jhj6NkKwEqym8UtSzsmSulcdCy+Fxm/A+lDvh8BoXUuS5YRZjjkR0I9dB85N2z9cfC PNHcncXxgtLLRTNaL4/ZAbbkY/e7MG4COgQE2GyKI0v3Vt4LOoR+eT74J3m/0+FvaCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796093194; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=/YPFHdU7TFBXPEuku0rWy1sOWZunM5jELNdcT6AunuU=; b=dJe+zgehqnltJUaKaSEG8dBTL+v7v6KdPOuB0TC1bmkA/9TOMcra27xur16b98matuZp xBvGWNplnc6XvRLrtWbGRsYsegKJwLerD1n2X/Dg943asNG/UPniocf9E+WnKykNva7vu HMsy47lAqpX+GUkwyfkO5FFa+XcH4tKVcnRYzFI3l6L2n+Pq5LJu7DrEjbiW9leRnaZZ6 D+4rUh8xl7vfvIrO1u8ONL7ikzXoEfh1nnyqpjCe44n9ClNK9+EKj15Ojj/yHaMXvA+8S 5CCG3pTG0u/E4zCGQfiEGE2h1CeFyfJpDDNvc0VrTVTJ7bhGlszcWz5TvPltnU604rQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=F0AookrH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70CCD606A329 for ; Tue, 1 Dec 2026 02:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=F0AookrH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 619901F000C1; Tue, 1 Dec 2026 02:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796093193; bh=/YPFHdU7TFBXPEuku0rWy1sOWZunM5jELNdcT6AunuU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=F0AookrHJd14s9tYi+MgoMP3fufylDtpxFP809TKk3zePnyEglJfS3kB+VZsHRQih 8A6ntfIjFB0a/m7v/giaDTln7P+kefoA2AIhHXYpYp2u62rw7qTbsLm6FgWWxkdf4L sjjp5S8JbQSDd8BuHki0MU3MHHga150P2oRRgT39ItojPAvCGBs3Hm4Me50wvsKdsn 1I41Wc1B9SBmnj64e2FuqQwUr8qpllrZslFcFA4zCt5YA3yAgoCJhqtYry792VJ4vV KdvIXnn7n14yjO6n39XXUxC0kTk4SLeFdAgX0AQN7DhjK54C0B/e6GlBlt9fUyWw6f +pTCNRQZ8jyyA== Subject: Re: [PATCH 3/4] net: ethernet: smsc9420: propagate mdiobus_register() errors From: netdev-bot+sashiko@kernel.org To: 18255117159@163.com Cc: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, netdev@vger.kernel.org Date: Tue, 01 Dec 2026 02:46:32 +0000 Message-ID: <179609319291.3146.16107243352034165029@kernel.org> In-Reply-To: <20261130023745.820141-4-18255117159@163.com> References: <20261130023745.820141-4-18255117159@163.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 2 · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] In smsc9420_mii_init(), the patch stores the result of mdiobus_register() in `err`. - [High] The commit message says that propagating the mdiobus_register() error, especially -EPROBE_DEFER, lets 'the driver defer correctly when… -- net: ethernet: smsc9420: propagate mdiobus_register() errors The patch changes smsc9420_mii_init() to store the return value of mdiobus_register() in err. Registration errors such as -EPROBE_DEFER are then returned instead of the default -ENXIO. > mdiobus_register() can return -EPROBE_DEFER. Return that error instead > of converting every failure to the initial -ENXIO so the driver can > defer correctly when probed from async context. [Severity: High] Is this description accurate for this driver? smsc9420_mii_init() is not called from smsc9420_probe(). Its only caller is smsc9420_open(), the ndo_open handler. That caller replaces any non-zero return with -ENODEV: drivers/net/ethernet/smsc/smsc9420.c:smsc9420_open() { ... result = smsc9420_mii_init(dev); if (result) { netif_warn(pd, ifup, pd->dev, "Failed to initialize Phy\n"); result = -ENODEV; goto out_free_rx_ring_3; } ... } So the propagated error is thrown away. Even if it were passed through, -EPROBE_DEFER returned from ndo_open would reach userspace as errno 517. It would not trigger a deferred probe, because deferral only applies to errors returned from a .probe callback. Also, the only -EPROBE_DEFER source in __mdiobus_register() seems to be the optional reset GPIO lookup, devm_gpiod_get_optional(&bus->dev, "reset", ...). This driver never sets a parent or fwnode on its bus. Should this change be dropped? Alternatively, the MDIO bus setup could move into smsc9420_probe(), with the commit message updated to match. > diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c > index 0c97211b6254e..6b563b0c7cb06 100644 > --- a/drivers/net/ethernet/smsc/smsc9420.c > +++ b/drivers/net/ethernet/smsc/smsc9420.c > @@ -1153,7 +1153,8 @@ static int smsc9420_mii_init(struct net_device *dev) > /* Mask all PHYs except ID 1 (internal) */ > pd->mii_bus->phy_mask = ~(1 << 1); > > - if (mdiobus_register(pd->mii_bus)) { > + err = mdiobus_register(pd->mii_bus); > + if (err) { > netif_warn(pd, probe, pd->dev, "Error registering mii bus\n"); > goto err_out_free_bus_2; > } [Severity: High] When mdiobus_register() succeeds, err is now 0. Does the next failure branch still return an error? drivers/net/ethernet/smsc/smsc9420.c:smsc9420_mii_init() { ... if (smsc9420_mii_probe(dev) < 0) { netif_warn(pd, probe, pd->dev, "Error probing mii bus\n"); goto err_out_unregister_bus_3; } return 0; err_out_unregister_bus_3: mdiobus_unregister(pd->mii_bus); err_out_free_bus_2: mdiobus_free(pd->mii_bus); err_out_1: return err; } Before this patch, err was still -ENXIO at this point. Now smsc9420_mii_probe() can fail because no PHY is found at address 1, or because phy_connect() fails. In that case the bus is unregistered and freed, but smsc9420_mii_init() returns 0. smsc9420_open() then treats this as success and calls: phy_start(dev->phydev); dev->phydev is still NULL at that point, because only a successful phy_connect() in smsc9420_mii_probe() sets it. phy_start() calls mutex_lock(&phydev->lock) without a NULL check. Can this oops while RTNL is held? pd->mii_bus is also left pointing at freed memory. Later, smsc9420_stop() would hit BUG_ON(!dev->phydev). After that, it would call mdiobus_unregister() and mdiobus_free() on the bus that was already freed. Would something like this restore the previous behaviour? err = smsc9420_mii_probe(dev); if (err < 0) { netif_warn(pd, probe, pd->dev, "Error probing mii bus\n"); goto err_out_unregister_bus_3; } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130023745.820141-1-18255117159%40163.com