From nobody Thu Sep 18 04:19:36 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 2B807C04FDE for ; Fri, 9 Dec 2022 15:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbiLIPfJ (ORCPT ); Fri, 9 Dec 2022 10:35:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229646AbiLIPfH (ORCPT ); Fri, 9 Dec 2022 10:35:07 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B020E6B9BE; Fri, 9 Dec 2022 07:35:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670600106; x=1702136106; h=from:to:subject:date:message-id:mime-version; bh=2nhTdbC2PR8CepBOOqGB8k4UrM29lA7Y0BC0ZtFimPw=; b=b2ARAgl1RAo9aR7WYQ6DF9cdP4aSq0jtviuRExlPGuU0v9qvhcjJFzcj GYSE45PaFVi2B77ssTIpf9kQPd1sf5PgSvHeN8LHdLTrSc4QRY6pNzBB3 07cX8/nlDBQos3ssKQemy/SeGe0HsgJPT0riHYDYQbxyNQO3pZVTBRsm0 x3+svwdqPQdh4Xl8q4rSC1ZML8cM5Z8IFItaTlTylhzPVPrQu31BUrik6 18XGzV3d42leilqzxtYaLkwfGx5Bz7FyOMjSzf+8XZfp8nwyC4AM4mrt9 peWGTkTI2UHr1daev0gx1unk6Nl/apJY7ZB9rSipkWynDzzRmKTeQVZh9 Q==; X-IronPort-AV: E=Sophos;i="5.96,230,1665471600"; d="scan'208";a="190907093" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Dec 2022 08:35:05 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 9 Dec 2022 08:35:03 -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; Fri, 9 Dec 2022 08:35:02 -0700 From: Jerry Ray To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , , , , , Jerry Ray Subject: [PATCH v2] net: lan9303: Fix read error execution path Date: Fri, 9 Dec 2022 09:35:02 -0600 Message-ID: <20221209153502.7429-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 Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- v1->v2: corrected email header: net vs net-next, Added 1 maintainer, removed blank line. No changes to the body of the patch. --- 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