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=1796451587; b=lkP0AndWW4lK4stW6xRukqJ9TvfoudoaQNzj52+tlMpi7pyxYdRRhF+FT4qTxuF03tJa OuCWh+0G9da3ofiTO6JqUZ8WuDhLQ0AZMfWqGlr+g7L/wstuqTMNNhtjoKPySYVeGrFv7 AA5flVvuY4NCMMB1n2ZhhcKl9NGONVNRFwBWvsyu9U4jK6fjn6zz0/dqWBLl9bdyciZIX hPqJyQqECEL2eUQNXlk12cy8uWbKukmKLD1zKWSCAp3IMSybC4TdzR3LHBJMk0Y7wWwSL fYc8DQeKLSo+FN/D85HuofYgW7zwa6hKZO0wS58KXkoudidr2viVT/YHzyejooqWm1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796451587; 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=47qtHBiJu6C1VX0F2Z8YuNDtzM264+QQSxtTmRI/4M0=; b=ZyXz1mys0X4Rqsz4NE8kUPQjK5ANB5CV0P0DMS4eTjVUFg8D1eq7jlw8BaxPdigWkXsR L/w738QlWVu3K21yE7V1ihqaj5r/qUPwmv2y0/NiA5KecBvYi0fXERPz74wuYkNJH8a12 nKnd1OeWmg+DyQ5AFY7wVD0zyf5mYUDeTRzy+zsOQQ/eoVRLjUz5UL51s3uozWDyJY8Pg GZ5UVjpvjgidh4kRN+dRYeoJu5sA41m2BrTdvx2OmHS2LbWUQhYDKbT21Ia7kv37NJCWU fgqJ6JShl9yopspVJ4TEUzhxTsbys6+Gw9nLapMze3yhRityf46LNFJgfcrwmapkP6w== 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=fiw7mtBM; 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 3D5AB606A322 for ; Sat, 5 Dec 2026 06:19:47 +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=fiw7mtBM Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75A9F1F00936; Sat, 5 Dec 2026 06:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796451586; bh=47qtHBiJu6C1VX0F2Z8YuNDtzM264+QQSxtTmRI/4M0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=fiw7mtBM0/b0oC3URE6zzHX50UOT4b4PeTbH7Sh2RtmC2On0v6RNs0esxor/4l5j2 NgGur6xUcKJBgb4xnqDWj/IxzVj6yXOc2qYlgZbhe17Jg0LdH+muiIytIQDqL8l/MW HWOMFfw4wuzgqdLrBhgUq/5ay3d2moFZwT6CkCBtPITyg0GPL6acFgqQ1AhCzLd0NA wrIZMAPuNGX/flSNHtpZ7AtReRrMRUBRQ8ZsB7mG3ZNobElG4GmSDau0nUzJRCJJum 9JzfntxLJHEemDR0bnAwBwvewP0HplnNLB7bjDVoSeYMI96eyqO2TYmoL27uTYCscl wQppxSe5ae82g== Subject: Re: [PATCH] net: cxgb: fix uninitialized variable in mi1_wait_until_ready() From: netdev-bot+sashiko@kernel.org To: mdshahid03@gmail.com Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com Date: Sat, 05 Dec 2026 06:19:45 +0000 Message-ID: <179645158599.3146.11396515266545524981@kernel.org> In-Reply-To: <20261204061548.59242-1-mdshahid03@gmail.com> References: <20261204061548.59242-1-mdshahid03@gmail.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: 1 · Medium: 0 · Low: 1 (1) 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] The fix is incomplete: the same uninitialized-value bug after a failed TPI read of an MI1 register is still present a few lines… - [Low] net: cxgb: commit message misspells __t1_tpi_read() as _ti_tpi_read Pre-existing issues: - [Low] All six call sites ignore the return value of mi1_wait_until_ready(): mi1_mdio_read (subr.c:299), mi1_mdio_write… -- net: cxgb: fix uninitialized variable in mi1_wait_until_ready() This patch checks the return value of __t1_tpi_read() in mi1_wait_until_ready(). When the TPI read fails, the function now returns 1 straight away, so it never tests the busy bit on an uninitialized val. > diff --git a/drivers/net/ethernet/chelsio/cxgb/subr.c b/drivers/net/ethernet/chelsio/cxgb/subr.c > index d4488e400bc6e..bb42155d273a1 100644 > --- a/drivers/net/ethernet/chelsio/cxgb/subr.c > +++ b/drivers/net/ethernet/chelsio/cxgb/subr.c > @@ -255,7 +255,9 @@ static int mi1_wait_until_ready(adapter_t *adapter, int mi1_reg) > do { > u32 val; > > - __t1_tpi_read(adapter, mi1_reg, &val); > + if (__t1_tpi_read(adapter, mi1_reg, &val)) > + return 1; > + [Severity: Low] This is a minor changelog nit. The commit message says: Check the return value of _ti_tpi_read before using the value The function whose return value this hunk now checks is __t1_tpi_read(). It has two leading underscores and "t1" with the digit one, not "_ti". As written, the changelog names a symbol that does not exist. Anyone grepping git log for __t1_tpi_read later will not find this commit. There is no runtime impact. Could you spell the function name correctly when you respin, preferably as __t1_tpi_read() with the trailing parentheses? [Severity: High] Is this fix complete? The same uninitialized read after a failed TPI read of an MI1 register is still there a few lines further down the same MDIO path. __t1_tpi_read() only writes *valp when t1_wait_op_done() succeeds: drivers/net/ethernet/chelsio/cxgb/subr.c:__t1_tpi_read() { ... if (tpi_busy) pr_alert("%s: TPI read from 0x%x failed\n", adapter->name, addr); else *valp = readl(adapter->regs + A_TPI_RD_DATA); return tpi_busy; } mi1_mdio_read() and mi1_mdio_ext_read() both declare val without initializing it. Neither checks the return value of the wait or of the final data read, and both return val unconditionally: drivers/net/ethernet/chelsio/cxgb/subr.c:mi1_mdio_ext_read() { unsigned int val; ... mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); /* Read the data. */ __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, &val); spin_unlock(&adapter->tpi_lock); return val; } mi1_mdio_read() follows the same pattern. Every caller ignores the new return 1 from mi1_wait_until_ready(). So after the TPI failure described in the commit message, execution goes straight on to the unchecked MI1_DATA read. The uninitialized value then leaves the function, where before it only fed a local busy-bit test. >>From there it reaches cphy_mdio_read(), which only treats negative returns as errors: drivers/net/ethernet/chelsio/cxgb/cphy.h:cphy_mdio_read() { int rc = cphy->mdio.mdio_read(cphy->mdio.dev, cphy->mdio.prtad, mmd, reg); *valp = (rc >= 0) ? rc : -1; return (rc >= 0) ? 0 : rc; } The PHY drivers (mv88e1xxx, mv88x201x, my3126) use that value for link, speed and duplex decisions. They also use it for read-modify-write of PHY control registers. It can also come back through t1_ioctl()->mdio_mii_ioctl() as the SIOCGMIIREG val_out. That would expose stack contents to a CAP_NET_ADMIN caller. Should mi1_mdio_read() and mi1_mdio_ext_read() check the __t1_tpi_read() result, or initialize val, and return a negative errno such as -EIO? cphy_mdio_read() already expects that. Should mi1_wait_until_ready() failures be propagated as well? [Severity: Low] This is a pre-existing issue, not one introduced by this patch, but none of the callers act on the new early return. All six mi1_wait_until_ready() call sites ignore its return value: mi1_mdio_read(), mi1_mdio_write(), mi1_mdio_ext_read() (twice) and mi1_mdio_ext_write() (twice). In the clause-45 paths, the INDIRECT_READ or INDIRECT_WRITE phase is issued even if the INDIRECT_ADDRESS phase never completed: drivers/net/ethernet/chelsio/cxgb/subr.c:mi1_mdio_ext_write() { ... mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); /* Write the data. */ __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val); __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_WRITE); mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); spin_unlock(&adapter->tpi_lock); return 0; } mi1_mdio_write() and mi1_mdio_ext_write() also return 0 unconditionally. A PHY write that failed is therefore reported as a success. The existing busy timeout (return busy with busy set) was already ignored by these callers before this patch. The patch only replaces undefined behaviour with a fixed early return. Could this be addressed together with the fix above, by returning -EIO from the MDIO accessors when mi1_wait_until_ready() fails? > busy = val & F_MI1_OP_BUSY; > if (busy) > udelay(10); -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204061548.59242-1-mdshahid03%40gmail.com