Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3183176pxb; Mon, 9 Nov 2020 05:04:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXiOuoT1RBcU0Kq8YgWwOxqLANygoaRVv6yYfDLscPb+q3oDqV/UnCXgiVTT6Stm1OMyjt X-Received: by 2002:a17:906:6949:: with SMTP id c9mr14866080ejs.482.1604927051283; Mon, 09 Nov 2020 05:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604927051; cv=none; d=google.com; s=arc-20160816; b=JfcazzBP5nkSaXRBpo8L2iZJviWN/5FeLVjPtuyqBr+etWD1sUEMVnNG8qhMpQxsnp 8k9tSBtG72A/9duosK6iQ8LxJ0Mk5duZMVutquXjSk3BubYckWGKpEUwa1tY6Wc58fth 5JEjd1ca15vo6CgaMtCPYRTQYDcKwVYtw4bO6/XHyliAOfIIMUlSjsaqbDrtMy+ZJieG PoxADqAxZXH+L9QUzvwFVrylRtXPLPHlhMUIz74a1mXBRwVno5Pr4mIzqf1fB9TrGZhA Bx8TLPUtIxCukcgJ75CRtD9+kfzDFqPTmXw2XUKmEeoj2EK2kLqB3kVudzb4U7N/IUAq LPLw== 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=lmaQ4Msk9WIMpUgu0Skz4yg5q90zX2VHIwGvWhZT10Q=; b=p5uFHakGloW/hQjKTvskBdHEMwHGZ6TG6Z5pI5bvsRYw/BrpYm1AbggQ1jGEF+KL9v 4r97M8TTL8cYzT9MhNYcGvQ0iJeBnV/be2lVntzljjGRclSKDxMDm6Ciw+oADgE8BRYO 6+i1kOWeChDYVTkvYaVRkVPb+AvbEXBgvB42B2UwdGCCiLWy0P5mQaLzIxc+8uORCSoS 1aCO7VVbVkFnovpjMAZ2RXdbCOTkOiY8MMa52120fTBgT8gH9V3xile4oSvFL8bY6S2C HQJZ2FAG/PlBOTHeSE/2+um9R1uEypaOIq8KxopqpfC1AlTcZRvgsbE+Ke4i3cj6nFUX 4Q3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lDc0gqe7; 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 62si7439149edc.231.2020.11.09.05.03.45; Mon, 09 Nov 2020 05:04:11 -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=lDc0gqe7; 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 S1730491AbgKINAV (ORCPT + 99 others); Mon, 9 Nov 2020 08:00:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:54326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730433AbgKINAM (ORCPT ); Mon, 9 Nov 2020 08:00:12 -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 F0914207BC; Mon, 9 Nov 2020 13:00:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604926811; bh=zZ7orDji2vb815BGMy8W7wwBHaPtZXTZ24EOyC1X92c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDc0gqe73viFOZyBkro6jVyO5Llsu6209jvvEnJrbmL+BX90zv0v5r6HkyfKx9V+a Y23n9GStOU4VMJqq2eT+6Si9vneafbewk69JRt7wBjmc9vvefKsKOdMtVGtOoebwei Q14RJrcUdJtQG4bbkwvnFYuRaa4OA1knoSbl3Slg= 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.9 005/117] ravb: Fix bit fields checking in ravb_hwtstamp_get() Date: Mon, 9 Nov 2020 13:53:51 +0100 Message-Id: <20201109125025.892293291@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@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 @@ -1729,12 +1729,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;