Article View: linux.kernel.netdev
Article #16024[PATCH net-next] net: phy: et1011c: don't write an error code to the config register
From: Elias Pukari
Date: Fri, 13 Nov 2026 22:19
Date: Fri, 13 Nov 2026 22:19
107 lines
14961 bytes
14961 bytes
et1011c_read_status() stores the return value of phy_read() in a u32
and does not check it for an error.
If the read of the configuration register fails, the negative error
code goes through the read-modify-write and its low 16 bits are written
back to the PHY, for example 0xdffb after -EIO. That sets 14 of the 16
bits of the register. The interface field (ET1011C_INTERFACE_MASK), for
one, ends up as 3 instead of ET1011C_GMII_INTERFACE. The function still
returns the result of genphy_read_status(), normally 0, so nothing
reports the failure.
If the read of the status register fails, the error code is compared
with the speed bits. For the usual error codes this does not look like
1000 Mbit/s, and the update of the configuration register is silently
skipped.
Make val an int and return the error of either read, like other PHY
drivers do. phylib then handles it like any other failed read_status():
it triggers a WARN and puts the PHY into the error state, with the link
down until the interface is brought down and up again.
Discovered by an AI agent (LLM) inspecting the code. The issue was not
seen on a real system. It was confirmed with a KUnit test, which is not
part of this patch and uses error injection: it binds the driver to a
PHY on a fake MDIO bus, brings the link up at 1000 Mbit/s and makes one
phy_read() fail. After -EIO it sees the value above written to the fake
bus (UML on x86-64).
With this patch the same test sees no write and gets the error back.
Not tested on hardware (no ET1011C available). Kernel selftests were
not run (none mentions this driver).
Fixes: dbb7a95d810a ("phy: Add LSI ET1011C PHY driver")
Signed-off-by: Elias Pukari <elias.pukari@gmail.com>
---
Notes:
How this was found and tested, since no hardware was involved:
The problem was found by an LLM (Claude) reading the driver. The patch
and the test were drafted with Claude as well. I have read both and run
the test myself.
The test is a KUnit test with a fake MDIO bus. It binds the real
driver, brings the link up at 1000 Mbit/s and makes one phy_read()
fail. On net-next d1f4b7c6b997 and on v7.3 (UML on x86-64, with and
without KASAN):
before config read fails with -EIO 0xdffb written, returns 0
config read fails with -ETIMEDOUT 0xdf92 written, returns 0
status read fails with -EIO nothing written, returns 0
after nothing is written and the error is returned, in all cases
The second value depends on the architecture: -ETIMEDOUT is -110 here,
but not on mips or parisc, for example.
The test is not part of this patch. I can post it if it is useful.
Also built with W=1 for x86-64 (gcc and clang) and for 32-bit x86,
allmodconfig.
I do not have an ET1011C, so this is not tested on hardware. For that
reason it is sent for net-next and without Cc: stable. I can resend it
for net if you prefer.
Not changed here, to keep the fix small:
- "speed" is a static variable, shared by all ET1011C PHYs in the
system, and it is updated before the registers are read;
- the return value of phy_write() is ignored, here and in
et1011c_config_aneg().
drivers/net/phy/et1011c.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/et1011c.c b/drivers/net/phy/et1011c.c
index 6cd8d7758..603fe5a1e 100644
--- a/drivers/net/phy/et1011c.c
+++ b/drivers/net/phy/et1011c.c
@@ -62,16 +62,22 @@ static int et1011c_read_status(struct phy_device *phydev)
{
static int speed;
int ret;
- u32 val;
+ int val;
ret = genphy_read_status(phydev);
if (speed != phydev->speed) {
speed = phydev->speed;
val = phy_read(phydev, ET1011C_STATUS_REG);
+ if (val < 0)
+ return val;
+
if ((val & ET1011C_SPEED_MASK) ==
ET1011C_GIGABIT_SPEED) {
val = phy_read(phydev, ET1011C_CONFIG_REG);
+ if (val < 0)
+ return val;
+
val &= ~ET1011C_TX_FIFO_MASK;
phy_write(phydev, ET1011C_CONFIG_REG, val |
ET1011C_GMII_INTERFACE |
base-commit: d1f4b7c6b997c29de67ad7178ababac2328cb1b4
--
2.56.1
Technical Details
Message-ID:
<20261113221917.3542509-1-elias.pukari@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362959-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362959-linux-kernel-netdev=dewy.ru
From: elias.pukari@gmail.com (Elias Pukari)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next] net: phy: et1011c: don't write an error code to the config register
Date: Sat, 14 Nov 2026 00:19:17 +0200
Organization: Usenet Network
Message-ID: <20261113221917.3542509-1-elias.pukari@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1453269"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:LsGVzD4llzq2KGmPPgVQ7c16GUI= sha256:igiV8EXQFXfDL1+MlKXtm3BRPUbyYEMtKwRi9ytkdeY=
sha1:ZQXBpssoU+Mlk29hkZorbQSO0IQ= sha256:GrTwFyK0s4B+tNVpWaXdzuQYzu4EamIeFDI/vI82uJk=
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 E82DD1146C7; Sat, 14 Nov 2026 01:21:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, 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=pass (2048-bit key)
header.d=gmail.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 siS4JIIO1lZT;
Sat, 14 Nov 2026 01:21:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-362959-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 874FC1146C2; Sat, 14 Nov 2026 01:21:00 +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 EB41A461DB; Fri, 13 Nov 2026 22:20:52 +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=1794608448;
b=arVapVb87uMZGul/56o69ui40p3xRVydlHkQLxoAE9gOwEAYvWPK5e7XD1Ta9I7Sa/EJ
DuXSsEKVu8EPipEsxhuaF5NVxYk/lkZKAe3u0liuLNcTwhAZMv8nqCl3XBy8nKDiaaOp2
SZ+LFoQAdxqkbndbEtDV68zptOdME4EKxjrbnBdqxe/bVeM93Ex7NRtGjH/Pk54+l2jww
MAl7scuop3gADfG1bf2hryCfJ00TJV5iIdhVF61C2sBHO7NMbtYsepJN4K2nIAoxFWiG9
b5GQlrohwlUZ53ODN+kAunyIf3S2fdaAO/QbFgzqtK2tJFHW+JbzeFbIyIT8MDJC6og==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794608448;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=awTWuz2Pbv3qMcNvqNUDXdB+FnmJ4OgUX7z3jOtQego=;
b=1Q84HISwbGnvTZ78vfEWuWYjgWeCbUp924YMj/BEj8FsXSOeuZzuLIP45QdP/6CHOtSL
LsLi91rQeW4gqOe4GS49CYpiTxnKmQkCjA2sNja3GCkAT57Y8UVdwTCp7gp+Je6EwzCzB
rZHYvFCK9jBu2Mowjxu9tMLeH9P+5q8xrs9US1d2kpDaS0qTYHN+MNX1t1P+24lcaNIBo
idxk1UctyMID/eH79tSnBjc0VOR5wyftK3svKou6xP5nVbKFcwUagAEckZ6fct6kLuknP
8uu/ymx57MyyQrUO1PC317O+7R8v8Q0EaLZt3aN8fA15U+QjWMCBBP3LVj3EWa9r7Eg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="EHo/TLyj";
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.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 17BC6606A890;
Fri, 13 Nov 2026 22:20:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=EHo/TLyj
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.171
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794608447;
b=RQY8U8ehN3i6Y4RXM3rxoQYY9x9WvyxAINpU8rG+B7sl5bmQt3/OMOnl7zbGPduek37L
XMgg3FQFHnzZVNPRva24fzj2XPh8B8N33VjdWQwgUCgxOFsPKRAuyqxuj9zHl5hP2ZwaA
uBDG3eIPNq5xHL+6VutvZnXVI3r5xwlc0ST1kwX8jBcyBgZUnIPCiGyzwIvo2XHXEKaTO
kHsMLv22TJuFx7Nx0aZx7uHbktOClg1WRzYPi8f70+z4ONAsu6mubOZG7QoYH6KbHI56j
NrGimJXsOjseQU/Pf8RTJaeZGNZFO0RQbt0triIZHRXLKk7SgHVnWn22JLvpereGbIw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794608447;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=awTWuz2Pbv3qMcNvqNUDXdB+FnmJ4OgUX7z3jOtQego=;
b=vO9vk4SW5SuHtjCtZ1ZewdRh6d0J0WxDzqP/JKwizsTIM+WFq35l8dCqzwoy2ksXB1uo
N5zdBe9D8pZGoejneJOhtsVyVrJzfVSIj1a83r6PpFvEgV4SnPug5rNgQ6+7bthscjfyL
Dud+J/4MZ3/LMt/6DKUvTwFqRQekadc8b7mzX9uocHb7BZLk/3mxnTZZUg7PtUWSoVN4V
sIox41KkELPD/XOEXk9b3mhF6flHrBPKjynHdhRvXszmRsejJH0egLw6GgEQPUnO57sqA
H4v49IR0s6pkHVd4P1pJgas27j4eL+5QTn6wvf1eWuuX7RjXQkSvaFeFFUEXa8r6zgw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="EHo/TLyj";
arc=none smtp.remote-ip=209.85.208.171
X-Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C4A3606A32E
for <netdev@vger.kernel.org>; Fri, 13 Nov 2026 22:20:45 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1C4A3606A32E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-3ae25c846edso15722031fa.2
for <netdev@vger.kernel.org>; Fri, 13 Nov 2026 14:20:45 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794608444; x=1795213244; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=awTWuz2Pbv3qMcNvqNUDXdB+FnmJ4OgUX7z3jOtQego=;
b=EHo/TLyjv+b+6c1JzMljB/XnMVizYTIKonHxM9wW6wHzUHS0ntvI4pKVbL0gbeb5Qy
dCWCYGQZK/W6yBc2Fi1HqO8bwT/BUgiJ4L+zMSsFvsPeS29JRqLA9ztkhEKgvWdPdzP4
C0CI5DzCtqpQM9ilS1UfuSg1W1zFcXea7xiUWY2SRd5uzeP2ZV9cr5OkyR1G3R9oDrfr
MZa9glg4Bj1nupn4zl4GeUyrLqkgwCMswd1kUQgAauWzavtGojEA1JHaIeKsKR2S1uka
XZcuDHzbmDozJga7eCNxw5fu+NdGK9yy6K0/TF4LBU2HyiS+MSWqncmimT2H/v8jKIA/
J43w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794608444; x=1795213244;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=awTWuz2Pbv3qMcNvqNUDX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3DXNT3wi9cphE3rbAQNV19kM4goeiDvsqZg4dzd+Hqvc95iBnkaqcIzaLo7ESZhxYHUJ
O+HkVix52Pee5qifGTPY8YMicQ6loPB8oIvrS+TeHLsXsJyiO/tDnGuCXgBbSYoFGFN/fjd3bSv
+oIT0xTEPHUKksjCddlvFCvpsFXxruL+C1GWaAGNuYvKwv4loZMEBQqsn33qLNMxF7AXL1jr77G
M6uDeUS9mfuNDekeoGhmTTFV3dqevZLTr
X-Received: by 2002:a05:6512:138d:b0:5bf:ce20:57e8 with SMTP id 2adb3069b0e04-5c1709c19c4mr1534065e87.40.1794608444157;
Fri, 13 Nov 2026 14:20:44 -0800 (PST)
X-Received: from localhost.localdomain (85-76-110-212-nat.elisa-mobile.fi. [85.76.110.212])
by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c171333630sm1137443e87.19.2026.11.13.14.20.42
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 13 Nov 2026 14:20:43 -0800 (PST)
X-Cc: linux@armlinux.org.uk,
davem@davemloft.net,
edumazet@kernel.org,
kuba@kernel.org,
pabeni@redhat.com,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Elias Pukari <elias.pukari@gmail.com>
X-Mailer: git-send-email 2.56.1
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