From patchwork Wed Jun 9 09:52:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 458457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 798BDC48BCD for ; Wed, 9 Jun 2021 09:52:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63CD161042 for ; Wed, 9 Jun 2021 09:52:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238436AbhFIJyb (ORCPT ); Wed, 9 Jun 2021 05:54:31 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:36312 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234390AbhFIJy3 (ORCPT ); Wed, 9 Jun 2021 05:54:29 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1599peam012994; Wed, 9 Jun 2021 09:52:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=L0iHNQ1Q5+MsI4CS1WUU69bxPrhaX+CRoYUVxNmpXCY=; b=IwNv9YBIcEKdQI9dJk5LeoSRatPi5FmXdIxuxttIZAZzaVCQusN6EGXgwEgPnvoReA6U UOYm/bEvGQ9q5LzBe7PMO0PlANibDVIzv5QjVKrP6kvQHWJ9g+JTLQcqF7xu8IQZqmIu +twjLNX6aWSEmV1S1zVG8w2M84AmvENYfx/C+pkN58AB0ppG4aBStE/QRCZKr4Ctl36g 9UFX25FpQUUFaWHfuZpHKS3cpIWZkc8/BGLPS2JbGk/DoMS0Tmry23rUHkJsy+PPTsAe 5nZ64AerfP9pK2X4UQsQUTL3qibBhGorpFpuyRtdztjrUlrzSg53wNQoqKGVOx/JIG6o kA== Received: from oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 392ptc83rn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 09:52:25 +0000 Received: from aserp3020.oracle.com (aserp3020.oracle.com [127.0.0.1]) by pps.podrdrct (8.16.0.36/8.16.0.36) with SMTP id 1599pnFp007005; Wed, 9 Jun 2021 09:52:25 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3020.oracle.com with ESMTP id 3922wug2mh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 09:52:25 +0000 Received: from aserp3020.oracle.com (aserp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 1599qO8X010928; Wed, 9 Jun 2021 09:52:24 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 3922wug2kk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 09:52:24 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 1599qKTs023002; Wed, 9 Jun 2021 09:52:20 GMT Received: from mwanda (/41.212.42.34) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 Jun 2021 02:52:19 -0700 Date: Wed, 9 Jun 2021 12:52:12 +0300 From: Dan Carpenter To: Andrew Lunn , Yang Yingliang Cc: Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 1/2 net-next] net: dsa: qca8k: fix an endian bug in qca8k_get_ethtool_stats() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-ORIG-GUID: GSl0_WKBTC5_G0XbDKkODo5dcjw1Yl7V X-Proofpoint-GUID: GSl0_WKBTC5_G0XbDKkODo5dcjw1Yl7V Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The "hi" variable is a u64 but the qca8k_read() writes to the top 32 bits of it. That will work on little endian systems but it's a bit subtle. It's cleaner to make declare "hi" as a u32. We will still need to cast it when we shift it later on in the function but that's fine. Fixes: 7c9896e37807 ("net: dsa: qca8k: check return value of read functions correctly") Signed-off-by: Dan Carpenter --- drivers/net/dsa/qca8k.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 6fe963ba23e8..9df3514d1ff2 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -1412,7 +1412,7 @@ qca8k_get_ethtool_stats(struct dsa_switch *ds, int port, struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; const struct qca8k_mib_desc *mib; u32 reg, i, val; - u64 hi = 0; + u32 hi = 0; int ret; for (i = 0; i < ARRAY_SIZE(ar8327_mib); i++) { @@ -1424,14 +1424,14 @@ qca8k_get_ethtool_stats(struct dsa_switch *ds, int port, continue; if (mib->size == 2) { - ret = qca8k_read(priv, reg + 4, (u32 *)&hi); + ret = qca8k_read(priv, reg + 4, &hi); if (ret < 0) continue; } data[i] = val; if (mib->size == 2) - data[i] |= hi << 32; + data[i] |= (u64)hi << 32; } } From patchwork Wed Jun 9 09:53:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 457422 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CB26C48BCF for ; Wed, 9 Jun 2021 09:53:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1CEC61375 for ; Wed, 9 Jun 2021 09:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238441AbhFIJzV (ORCPT ); Wed, 9 Jun 2021 05:55:21 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:17178 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238448AbhFIJzU (ORCPT ); Wed, 9 Jun 2021 05:55:20 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1599pccj006669; Wed, 9 Jun 2021 09:53:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=S/qcMO7tg70TWSG285PucZXlxuXsoTBcX4MUtOs0lzQ=; b=eUqjwonPcrNQNVRUhhy+lflZxT8VH7KF61Yuf8Otw2A4q9iUKmEqK2BwIYZBbsDjbAYM OoGfTEhVT8ndrvVmGaLxvJDmNDqwwXibsJoP+C/2OdTBMNiQKfm36E92AXwgkiVqxDK/ RR4p9kfWv/1vE7hDbucCE+Hc38mjdht21m0rHfxeWzJJQ5SkFrDnucTQmw/xuvXQbgRo HjbI72Pd6nA98sTQQNewFw9XNrmI81lJUv8JkUXCrLycCf0IKbzRYgIDEDi4OBBVcqpl jbzjUaZsFX04uz+dpvAWHA7d3eSrhecxo00ZAi0rBrthb2Ahvbl+JP5qcdp59ILYmnaU nw== Received: from oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3926dh8eej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 09:53:16 +0000 Received: from userp3020.oracle.com (userp3020.oracle.com [127.0.0.1]) by pps.podrdrct (8.16.0.36/8.16.0.36) with SMTP id 1599pnhp181059; Wed, 9 Jun 2021 09:53:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3020.oracle.com with ESMTP id 390k1rsmv8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 09:53:15 +0000 Received: from userp3020.oracle.com (userp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 1599rEVA183088; Wed, 9 Jun 2021 09:53:14 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 390k1rsmuw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Jun 2021 09:53:14 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 1599rBTg010829; Wed, 9 Jun 2021 09:53:11 GMT Received: from mwanda (/41.212.42.34) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 Jun 2021 09:53:11 +0000 Date: Wed, 9 Jun 2021 12:53:03 +0300 From: Dan Carpenter To: Andrew Lunn , Yang Yingliang Cc: Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 2/2 net-next] net: dsa: qca8k: check the correct variable in qca8k_set_mac_eee() Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email haha only kidding X-Proofpoint-ORIG-GUID: pRvR0IkDCi0pyCOCbQcxZO4wREhhhL0- X-Proofpoint-GUID: pRvR0IkDCi0pyCOCbQcxZO4wREhhhL0- Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This code check "reg" but "ret" was intended so the error handling will never trigger. Fixes: 7c9896e37807 ("net: dsa: qca8k: check return value of read functions correctly") Signed-off-by: Dan Carpenter Reviewed-by: Vladimir Oltean --- drivers/net/dsa/qca8k.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 9df3514d1ff2..1f63f50f73f1 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -1454,10 +1454,8 @@ qca8k_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *eee) mutex_lock(&priv->reg_mutex); ret = qca8k_read(priv, QCA8K_REG_EEE_CTRL, ®); - if (reg < 0) { - ret = reg; + if (ret < 0) goto exit; - } if (eee->eee_enabled) reg |= lpi_en;