Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4818689pxk; Wed, 30 Sep 2020 12:30:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF05utoKhEJiY+aUmZXRWeJE13j0Xh080R9exxUztZ8N7a0aO8mTSxhXby/FPn0KL6F/Bt X-Received: by 2002:a17:906:4805:: with SMTP id w5mr4629063ejq.313.1601494247250; Wed, 30 Sep 2020 12:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601494247; cv=none; d=google.com; s=arc-20160816; b=qKCpq8V7T6vNl1+qiMouhnGxEgRv2pAGJ5HzFgIprOkNb+kJyR5mVFFixLjPfCAzcL NpUyYEnVZqsJoF10GPhqkJQ7rQlnnWGsmjdJ/1K7bKMJzz6ZuehnmQOqlgi0QvIM87gl nELyL/BJB2lDOlfCO6WYMQ6p+lbIw3bYJJ3IC0JrLb7J/h5xmRWS3DatIpSMc2YOAfmf 6lwOoSVpp3JjAio5/U4AlzkLNhpglTXi4EJKGKzKJa3Mj4EqznUi5bsByngqd/q5a228 g7XZQPpWzqsCkvDYR2jTFEw84zyPlknsY/QWX7mCA9AX7lz3jmgQJTzt0TugOhec3oXm BARA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:ironport-sdr:ironport-sdr; bh=ogARUc01NAilvAkHZDfH0pArs3Ovf9CrU1XLfbzIOZM=; b=NmunIhDW1EYZByjZxSBjcIS6mJ1y1u766fx1+Kbn0gWB+1IkScvJiJBfPVDt6qKfmO neGc5Ge7D7z5/bOmGrrnRsCAOI7q45DI2+Lgxc7YIcaGJoUt1uw3V5q1Ni/wMP40g8bK hwdNgzv0q+VbMb0zdAkg9LebNQN+yUN4+8lkWG3LPIy1aR4C13JdbpsUBSBAzc0KcGjG BAwsh4OEBFKWrJ6ztXg/9gKtJ9tfRCMbhKiWtxWugV+liO2qE5jx6p83xcSiKGZiSZtJ lfYtEjqnEwrN8KDIBRyuoiMnfqOx5+3Gx+8ufZsoQwmDEpRMUkQsUXbFhyj9zTmthC6a Lc/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l2si1895278ejb.423.2020.09.30.12.30.24; Wed, 30 Sep 2020 12:30:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728721AbgI3T3V (ORCPT + 99 others); Wed, 30 Sep 2020 15:29:21 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:8472 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbgI3T3V (ORCPT ); Wed, 30 Sep 2020 15:29:21 -0400 X-Greylist: delayed 427 seconds by postgrey-1.27 at vger.kernel.org; Wed, 30 Sep 2020 15:29:20 EDT IronPort-SDR: 79Y+dQNdbeABQCfzpyJGfU1sh1XoRyQaVczTlK10vCjQxJQ4sSkyPTfz1X4sCabjqIHZ+0q2ce n0dckxVONw1h+2mYHVwtmM4SGUNFJW+XRpOCWA8zmVzXtdiJJbyyLnaPiv+kRGpJkmwFF24VqF JUZ3VwYkGfnhlVyBG+xxrLLZqabOFG8UE52L/I+jThnBViJs9zdrsBVWoeXHMvGAse3Tr8d8QB 4vT1QCnEqOnm7YA0kbIN5Y8XN8pLJO2X1TCxYWsJ264IGd8O0dqM8Fblk/0sGImsq85+A5/8rA Ff4= X-IronPort-AV: E=Sophos;i="5.77,322,1596528000"; d="scan'208";a="53432061" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 30 Sep 2020 11:22:13 -0800 IronPort-SDR: XYbYlObdcqtCz/2S2ePqINMCdlQmkUbA6J6SFwP3KrWiEWlIh3QNBTdiybCzBUHyUIis4G7NFk DgKgYHpsX0O4EtJAn1XU2ggBKTNtN9qdDlmRUNGDk5tBztwxyvhFOy5yty1W4SEsZufiS7hWKl PZPCxK79KYEskJKS0y2NLKGGP0bigw5GfIWmb2TcTJngC0RGlaucEiJKiKE9MEWE/Rcx+k2U3o pNbVerm+2nELL76EYh1JElJum2cVeLIxEyqkiPF1XPMXug4y/BZBrQNh4Ju1KH/w/2W6jN+yO8 ktg= From: Andrew Gabbasov To: , , , Sergei Shtylyov , "David S. Miller" , , Julia Lawall , Dirk Behme , Eugeniu Rosca , Andrew Gabbasov Subject: [PATCH net] ravb: Fix bit fields checking in ravb_hwtstamp_get() Date: Wed, 30 Sep 2020 14:21:24 -0500 Message-ID: <20200930192124.25060-1-andrew_gabbasov@mentor.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the function ravb_hwtstamp_get() in ravb_main.c with the existing values for RAVB_RXTSTAMP_TYPE_V2_L2_EVENT (0x2) and RAVB_RXTSTAMP_TYPE_ALL (0x6) if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_V2_L2_EVENT) config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; else if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_ALL) config.rx_filter = HWTSTAMP_FILTER_ALL; if the test on RAVB_RXTSTAMP_TYPE_ALL should be true, it will never be reached. This issue can be verified with 'hwtstamp_config' testing program (tools/testing/selftests/net/hwtstamp_config.c). Setting filter type to ALL and subsequent retrieving it gives incorrect value: $ hwtstamp_config eth0 OFF ALL flags = 0 tx_type = OFF rx_filter = ALL $ hwtstamp_config eth0 flags = 0 tx_type = OFF rx_filter = PTP_V2_L2_EVENT Correct this by converting if-else's to switch. Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Reported-by: Julia Lawall Signed-off-by: Andrew Gabbasov --- drivers/net/ethernet/renesas/ravb_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index df89d09b253e..c0610b2d3b14 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1802,12 +1802,16 @@ static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req) config.flags = 0; config.tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; - if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_V2_L2_EVENT) + switch (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE) { + case RAVB_RXTSTAMP_TYPE_V2_L2_EVENT: config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; - else if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_ALL) + break; + case RAVB_RXTSTAMP_TYPE_ALL: config.rx_filter = HWTSTAMP_FILTER_ALL; - else + break; + default: config.rx_filter = HWTSTAMP_FILTER_NONE; + } return copy_to_user(req->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; -- 2.21.0