From patchwork Fri Dec 9 15:35:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Ray X-Patchwork-Id: 31836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp849494wrr; Fri, 9 Dec 2022 07:47:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf5L7wWR/i2vQoKceRQzG8RLAsWqEf9iR0RJdVZSfhHOjoGBcqAATdGcm8rX3LYv5zmKwIIi X-Received: by 2002:a17:906:1709:b0:7ad:88f8:7e2a with SMTP id c9-20020a170906170900b007ad88f87e2amr5436974eje.35.1670600829928; Fri, 09 Dec 2022 07:47:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670600829; cv=none; d=google.com; s=arc-20160816; b=Bws80SgBfHiVWn36jQ4F7/LnDr+NUOpXdot9+gxhporlHJqmQMgvCScTxoSvq6leQO RGf9n+HU+4ckwgW3G/uQsCvZ+SL8uYC42o9QY1WPu0fjkMe4Wjr843WOFZENHxEqYj9R /JgS3dCAAdbdqdlc3DJYHmX1sSr0In+6oGVynvMFDP8FCgRhQt2E95CZj34uVTuCh8vR 2jKF424nDeBwMy8ZUfStopFJhzRdmBZxIG8m1vIvQpJTtK9KN+FKna8UPgl5VhulwjJ+ uFQ1miFpRVajc0RPwEXTTwxYRLSKoNu8OSd+5brinaj7/kjLYhx8xTvggu5EghYIEL7r SBgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from :dkim-signature; bh=vPu1TnA9S5JB20iz30vTInnZhejD3tY/wVKnR/slYgA=; b=l3q8nfajLU1/CqV6YuQHFIrdeyE7S4aHVIux85Ck4SQMe5G+Aa04WOQVfdPN3oOXMZ 9h6lgPqARnvDBaTYBxBBi0VM/2WN47p7GohRniL3RGKYOX4usZakX+yydGw7rYDG1Lu3 BNFnP5EFPd5RnLoLDo9kVQsJzfuVIncLhFzUL5JEL6gLTOgZicdS2YOhoz+YvHj5YUGI X2hxP/NIshksiQowwJ+E8RhbutO1Ksl+qXGhku3+t+qGVzfYNS3KmvpQxwajGYunF6WW FgRaTYP+SDKNJN3bLeL0kREo6bQ46bQQoC/DPxLU3cko6iu3UKg23DATDbIEWC3BEWSM Z5Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=b2ARAgl1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs7-20020a1709072d0700b007c10534516csi86991ejc.554.2022.12.09.07.46.45; Fri, 09 Dec 2022 07:47:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=b2ARAgl1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbiLIPfJ (ORCPT + 99 others); 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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751751935598924455?= X-GMAIL-MSGID: =?utf-8?q?1751751935598924455?= 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-LAN9303") Signed-off-by: Jerry Ray Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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_switch *ds, int port, ret = lan9303_read_switch_port( chip, port, lan9303_mib[u].offset, ®); - if (ret) + if (ret) { dev_warn(chip->dev, "Reading status port %d reg %u failed\n", port, lan9303_mib[u].offset); + reg = 0; + } data[u] = reg; } }