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=1796288252; b=UHVxuFIS1vq4i4KpL36og8M9HPl7scn+NYgBd0719+a7gUU3MNUcVbwjVGMCsv24O76v wdhnbwMvZMZ+PV2ufH+ij26BxQRxJBNx0dMcjIzNWIWyAu5JqdH1wxd7vdCwuInnzIgcB mtlDA7HSXO/6kmJN+VBJXs6+WfDMHH9GE2fxN3kZAFATpSJPWJtnn5QaMuDigN7bX3lnh 1AgcQVU5uuwHyPb4KjJaX36xODDTUCPLz5ve2GjDd8eXS5bKbVNAdASnpOWusD7zjLEYy CzHiQgfKyzoLRA75x6VKGuOfGrWMw/H/TiPSm1j2dgKXatTNcGCRFyzG6BLnuAztUmg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796288252; 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=BhX9tfjVnj5Xwdqob1uena9CTmmAyd1+Aihh31GrZyY=; b=rmLiBbBp3Ml4TQQHLRBiQzuv12EVANJWQz4h+q63M3IH56xG2rkpCSbAkp7hsUYGvYED gBXWE7JQrsQSgqrUlF8/f87QdrOZ6PvR4bMxmPmbX7JHeq9jfXxQ561IErikiRIk2LfPB iI5uqFZ1bz5YzOJqSI92Ku5vRzKAS7SSi3BQ78HgY7Nr0xiD+sQVCWk6ekW2ouNsTwSA1 WUodyj4EZVEf+NWz22Os27wwWNlFrmpq8gAGlwt3KQlsfauPFYzn52l9o7FczIHENlRS+ 109aXPPmo5r8FAQUmdscN89hzzaVDhm4J2jM/X45IXfUTJt4USPuJv49EK4lG+7P7uw== 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="Kyxz/vIk"; 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 76B37606A33D; Thu, 3 Dec 2026 08:57:32 +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=Kyxz/vIk Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC5BF1F000C1; Thu, 3 Dec 2026 08:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796288252; bh=BhX9tfjVnj5Xwdqob1uena9CTmmAyd1+Aihh31GrZyY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Kyxz/vIkb+3VcFDBN6/ttblab2QJq0HR0lI1N3aRGWzh001LxNg5yGPbHf9KbtXv8 xWCdCLJVa6QaYP7WUE9Nyu8mqVNHBAyXkchOHe5OKrmrXW2JFQZO7EZKtkCJx90Kft hd6y8l9f9JLaYV+lOMU0diRqUVZaSMTbb0i9QzVFculzS7d2BgiYbjGBW4UdX5ryZE M6R6EwUL3o4EYHC6Fny95FrQC9It34+oFX0JhipUHpAZoeOCxhajh+KFBMhzkssiRV DslSKXAVisD2SBygO7A0DUAG39719j0woOc7wQkF0C4axREQOoBuZLvLnP+E+t2Z3M THC/Nl8eFkwcg== Subject: Re: [PATCH net-next v18 3/6] net: dsa: motorcomm: use GENMASK_U32() for mbus phy_mask From: netdev-bot+sashiko@kernel.org To: kyle.switch@motor-comm.com Cc: andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mmyangfl@gmail.com, horms@kernel.org, linux@armlinux.org.uk, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, david.laight.linux@gmail.com, ming.xu@motor-comm.com, xiaolin.xu@motor-comm.com, jianmin.wang@motor-comm.com, wei.zhang@gl-inet.com, sijia.huang@gl-inet.com Date: Thu, 03 Dec 2026 08:57:30 +0000 Message-ID: <179628825045.3146.10499037245243838808@kernel.org> In-Reply-To: <20261202084022.3716891-4-kyle.switch@motor-comm.com> References: <20261202084022.3716891-4-kyle.switch@motor-comm.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: devicetree@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 more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The commit message of "net: dsa: motorcomm: use GENMASK_U32() for mbus phy_mask" says "GENMASK_U32() also lets the compiler reject out-… - [Low] yt921x_mbus_int_init() (drivers/net/dsa/motorcomm/mdio_bus.c) leaks the mii_bus on the invalid-max_ports error path. -- net: dsa: motorcomm: use GENMASK_U32() for mbus phy_mask This commit changes how yt921x_mbus_int_init() builds the internal MDIO bus phy_mask. It now uses GENMASK_U32() instead of a (u32) cast of GENMASK() and drops the explicit cast. It is described as no functional change. > GENMASK_U32() also lets the compiler reject out-of-range masks at build > time. [Severity: Low] Does this hold for the call site changed here? In yt921x_mbus_int_init() the high bit is max_ports - 1, and max_ports is read at runtime: max_ports = priv->series->max_ports; GENMASK_U32() goes through GENMASK_TYPE(), whose input check is: include/linux/bits.h: #define GENMASK_INPUT_CHECK(h, l) BUILD_BUG_ON_ZERO(const_true((l) > (h))) const_true() is 0 for non-constant expressions. -Wshift-count-overflow also only fires for constant shift counts. So no build-time check applies here. The only bound on the shift is the runtime check: if (max_ports == 0 || max_ports > ARRAY_SIZE(priv->ports)) { This works today only because YT921X_PORT_NUM is 11. Nothing ties ARRAY_SIZE(priv->ports) to BITS_PER_TYPE(u32). If ports[] ever grew past 32 entries, the shift inside GENMASK_TYPE() would get a negative count, and the compiler would not warn. The earlier commit "net: dsa: motorcomm: use max_ports in series for port bounds checking" has a similar problem. It says it validates "the u32 width of phy_mask", but it only compares against ARRAY_SIZE(priv->ports). Could this sentence be dropped? Alternatively, adding BUILD_BUG_ON(ARRAY_SIZE(priv->ports) > BITS_PER_TYPE(u32)) would make the claim true. The code change itself looks correct for max_ports in 1..11. > diff --git a/drivers/net/dsa/motorcomm/mdio_bus.c b/drivers/net/dsa/motorcomm/mdio_bus.c > index a06e2cc94a3e2..94087c9962cca 100644 > --- a/drivers/net/dsa/motorcomm/mdio_bus.c > +++ b/drivers/net/dsa/motorcomm/mdio_bus.c > @@ -173,7 +173,7 @@ int yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp) > dev_err(dev, "Invalid max_ports: %u\n", max_ports); > return -EINVAL; > } [Severity: Low] Does this return leak the mii_bus? Earlier in yt921x_mbus_int_init() the bus is allocated: mbus = mdiobus_alloc(); if (!mbus) return -ENOMEM; The return -EINVAL above does not call mdiobus_free(mbus). mbus has not been stored in priv->mbus_int yet, so yt921x_mbus_int_cleanup() cannot free it either. The of_mdiobus_register() failure path just below does call mdiobus_free(). The current yt92xx_series_table entries cannot reach this path, since max_ports values of 11 and 9 both pass the check. The check came from the earlier commit "net: dsa: motorcomm: use max_ports in series for port bounds checking" in this series, and the leak is still there at the end of the series. Could the max_ports check move before mdiobus_alloc()? Calling mdiobus_free(mbus) before returning -EINVAL would also work. > - mbus->phy_mask = (u32)~GENMASK(max_ports - 1, 0); > + mbus->phy_mask = ~GENMASK_U32(max_ports - 1, 0); [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202084022.3716891-1-kyle.switch%40motor-comm.com