Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4478554ivc; Tue, 3 Nov 2020 13:05:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1xwVA9RBdCdJMRJpau3orJeYXUkaD22ZPdix7XDy1Luy3TRVIn/hwhxibIamXOuVJjVjI X-Received: by 2002:a17:906:af47:: with SMTP id ly7mr23201660ejb.532.1604437519723; Tue, 03 Nov 2020 13:05:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437519; cv=none; d=google.com; s=arc-20160816; b=IAN2UGnMTSMt2pA332elma1BS7tHwrp7IL+ZhOogy0MmgatRdBZAQ5vG5RmfH2VCmi 4ZfRQJw+XP6MKoc6aXEI4wJuu7f3cjNfsjMSSrmMyG3Z2W04F9yqrD6xekdmUd5JcNOP ZI3YHMxByf9rLY8HRo2kGUvVFkkkinq4X4bD6D6og93okTdzJhQXuUsn1/1imNs2wjVq qxqr7/iFde7aeJmBSu0JXiC5c4RdqK+1xxtS4opTWV6/TMqhvhCJKgKCbxsG+UfzAq9W gr2ji5772EgjhnHY7crSDF2FTmEyTfajblPOIsQyWvgAQlgCN0AHhZHhNfkQTHpCDQbX xrwQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KgtfgVJntCt9yV56o9e1xeiwn4xlQABi1NnAn1oqUKc=; b=RqwKVbkGzOdaczGNq/ySP6DdRNUMK4zM6lSQcmJjI0rYPWAk83je9MzT3ZYBiOK2SW Azg/QLIYZsu/V09SIjYAF3KPUcqVxqOUyID+A9jcFdN1NpYK71Q2ST2FHs9FyOCTp0rh s7Hvun910VpGgf83MtEDL3lMk12ALQT3olb0j3UKXUvRFdXavlQNLUDknDCOBp/nmAUl xOSDDKP5Qt5fPu6E1+W3rW9GqFSf/aYg41RaWKD+3HDlklXy3mO+zdDI7EXTn4Np8Hxl Lz+Xo+aognMIltgxslyLraGLSDSTzsUzrfiNiq89wrKEeMlD45JyeHg4z8CrooMpnWqg kTtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qTgoXLUm; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si10600269edr.82.2020.11.03.13.04.56; Tue, 03 Nov 2020 13:05:19 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=qTgoXLUm; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387484AbgKCVBf (ORCPT + 99 others); Tue, 3 Nov 2020 16:01:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:38120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387466AbgKCVBa (ORCPT ); Tue, 3 Nov 2020 16:01:30 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DAAF42053B; Tue, 3 Nov 2020 21:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437289; bh=mX3A9QtKPnMdDiEjJ255wtKeSxQwf6J7lHxGdHF17fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qTgoXLUmsNR+DwQH8x+vk35el9sgDvtHGAUfyrk+2t6E7j7WsXKDPdgfcBjMmEJyR Y4J1XWTVuCRJsTJ9hWiE1iwntECUciuaUmZ1YEjhZYPHsHI5wWu92i/Li1poPqEhx4 FPf03k/3TlO9z3qXGW+mcqv45Xz9joTMwNTCHqLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julia Lawall , Andrew Gabbasov , Sergei Shtylyov , Jakub Kicinski Subject: [PATCH 4.19 013/191] ravb: Fix bit fields checking in ravb_hwtstamp_get() Date: Tue, 3 Nov 2020 21:35:05 +0100 Message-Id: <20201103203234.400357360@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Gabbasov [ Upstream commit 68b9f0865b1ef545da180c57d54b82c94cb464a4 ] 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 Reviewed-by: Sergei Shtylyov Link: https://lore.kernel.org/r/20201026102130.29368-1-andrew_gabbasov@mentor.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/renesas/ravb_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1732,12 +1732,16 @@ static int ravb_hwtstamp_get(struct net_ 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;