Article View: linux.kernel.netdev
Article #26222Re: [PATCH net-next v18 3/6] net: dsa: motorcomm: use GENMASK_U32() for mbus phy_mask
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 08:57
Date: Thu, 03 Dec 2026 08:57
94 lines
11842 bytes
11842 bytes
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
Technical Details
Message-ID:
<179628825045.3146.10499037245243838808@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376415-linux-kernel-netdev=dewy.ruReferences:
<20261202084022.3716891-4-kyle.switch@motor-comm.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376415-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v18 3/6] net: dsa: motorcomm: use GENMASK_U32() for mbus phy_mask Date: Thu, 03 Dec 2026 08:57:30 +0000 Organization: Usenet Network Message-ID: <179628825045.3146.10499037245243838808@kernel.org> References: <20261202084022.3716891-4-kyle.switch@motor-comm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2441380"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:CUH9hlRFYcI1gPquCwJUkec3kDI= sha256:92EWILWbBNqr7aGtATs//hAgjhrVPR/ftWulQO1xKZQ= sha1:pFN0xibs7TWWS7TWzmgBH/+4C+0= sha256:rfRST8+1UiY/0Fm46nWDRpu9M9740SY9fvxna7J68M4= 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 1FE65117890; Thu, 3 Dec 2026 11:58:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=pass (2048-bit key) header.d=kernel.org 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 zkgxLTaQ95z2; Thu, 3 Dec 2026 11:57:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376415-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 88D1B117889; Thu, 3 Dec 2026 11:57:49 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 07A18265E3; Thu, 3 Dec 2026 08:57:46 +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=1796288263; b=3bAQ3opEfeLklVQU+VdN/sO7HgPpkSfW3xVvMybUoMffBaO2yFSX9dYjzJ6Ve3PoXhCT z1/KYxLnmxwf3UEYDCF2ls3rdowwZbUCJt5A7XvYIBGrPl+06s4ZcXpIwTnEeisgIPi9A u6C2qUSrL5aUi9SrlAfVfNTJl5zqLpqp4wms6T9EkkXymB+L4ijf8srTlUqidYssF0u4L 1U7TLFR4pPr9AssvIKbFn249dsJ9XYP7TuiXuAnwXNhZV0TGqvRiSPHPfpHLDdesa6JNR nTHI/LbT5NOxhu+O0rn1hAJpHrbNCJxTS7k1phEF9/L4ydKmEi7Lu1yI+va2XfG5Pfg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796288263; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=BhX9tfjVnj5Xwdqob1uena9CTmmAyd1+Aihh31GrZyY=; b=vhMg9izIDyU3n4owlBY6h5rbbzrZk/c8xvCHsclSCaYjKd6gsSyPm3O+awp6VaQuwtK3 lJzJq5nQ/ey5BJDonfVicMhfRgKWX4aS++GaZ6YzMak1JNQnns6dyReZqmygFH5WsTgkK K0fJjnAD9KBEOXq+XXQFiq1xv32BMm4+xWt7ptH/Qr5oW//c1l/igpyJRB0c/S3KOXoV3 YCF3Q4NnSY9IFvaq0Sht3eCSyIkk0Ufb45XffZfFfYcMpYowPV4FmKMNLW5/PLrW26a7H pa8KL8eNWXqscEQZKSa1bNuLohxyE/ukDpUWcFdYu+TO6mbYeqfd3beK0IAXXD1Gn2A== X-ARC-Authentication-Results: i=2; 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=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 58BC4606A685; Thu, 3 Dec 2026 08:57:43 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-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== X-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== X-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 X-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) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC5BF1F000C1; Thu, 3 Dec 2026 08:57:30 +0000 (UTC) X-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== X-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 X-In-Reply-To: <20261202084022.3716891-4-kyle.switch@motor-comm.com> X-sashiko-severity: Low 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