From nobody Thu Sep 18 05:53:34 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF4BFC10F1B for ; Thu, 8 Dec 2022 19:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229564AbiLHTaP (ORCPT ); Thu, 8 Dec 2022 14:30:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbiLHTaM (ORCPT ); Thu, 8 Dec 2022 14:30:12 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC5519B2A3; Thu, 8 Dec 2022 11:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670527811; x=1702063811; h=from:to:subject:date:message-id:mime-version; bh=NOuLtBAEfPRVp4erYU2PYxtgRLXk4Rc5kofNmn0gXUs=; b=yV9W5ZFIUQ/95TJFWgg2RuzSDIOgV/OJgp6KDp64mjmzrriIk8cyi5CS Qht1XRqHEOD3HQlO29Tz52ShzVRU9+CzJa8Kfz9PyqyGiXwK17sv5UxTC Lt1lC/vcLWudeMrO7OMxNlB2XTeLQarVEwoJ6cxmy9oXuKD+EUG3knIYC SHaVxpz0nLDh3pv9opYjEdNmwK+4QJBY+wKrFaEl2wmuWhKjpecaj6ImX Hc5rKOWZJrKfOdur1KryRBe5X2n/m9sNgkdHrLGtZGEoXNIFh9P2+EplR awMOH9GXVfhpbcn7+f7R1dsyWLZSP+rUrO6jnM6GYJvS2vzsxOizaRmvp A==; X-IronPort-AV: E=Sophos;i="5.96,227,1665471600"; d="scan'208";a="187244671" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 08 Dec 2022 12:30:10 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Thu, 8 Dec 2022 12:30:08 -0700 Received: from AUS-LT-C33025.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Thu, 8 Dec 2022 12:30:06 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , , , , Jerry Ray Subject: [PATCH net-next] lan9303: Fix read error execution path Date: Thu, 8 Dec 2022 13:30:05 -0600 Message-ID: <20221208193005.12434-1-jerry.ray@microchip.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch fixes an issue where a read failure of a port statistic counter will return unknown results. While it is highly unlikely the read will ever fail, it is much cleaner to return a zero for the stat count. Fixes: a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9= 303") Signed-off-by: Jerry Ray --- drivers/net/dsa/lan9303-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 80f07bd20593..2e270b479143 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1005,9 +1005,11 @@ static void lan9303_get_ethtool_stats(struct dsa_swi= tch *ds, int port, ret =3D lan9303_read_switch_port( chip, port, lan9303_mib[u].offset, ®); =20 - if (ret) + if (ret) { dev_warn(chip->dev, "Reading status port %d reg %u failed\n", port, lan9303_mib[u].offset); + reg =3D 0; + } data[u] =3D reg; } } --=20 2.17.1