Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp625937pxv; Thu, 15 Jul 2021 11:52:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyPFx8Jtxrr6Lm+Lwcz78H9EPCBLT35UKiLhADlj29ck31kQgoB8ApyLHvyo1czRIdogaY X-Received: by 2002:a05:6e02:de6:: with SMTP id m6mr3624115ilj.203.1626375162570; Thu, 15 Jul 2021 11:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375162; cv=none; d=google.com; s=arc-20160816; b=pqjGoxzkMz1V+cFdzCMcM9obRuTIKSFKfVrg+ocK0IH6nNJi+RYNDRVfnzLWz2mMQp +MjgmSnM0T7ZtzmfrlZEEog0+rhGB4rBMF9tmxAQzOaNVFhl49mZnI4GqT9+ouxgzHXW NQdCST5QLkYYnMaPQys/DzA1ehBaCxClAP0u/gnRU+rkvmPRIPvNVtcai6/wDLJMzIaF j9rZ0NFr0acI7KW7gj3Vcy7ZRcFgCXEWvJoIcrjVOJ6zYUq5mRj3Fs1pN+eqhVA6R8qr bexcmGQ0XnOmq8bSc8C63bs32P1n+P0r7z2S4BSZAdW1KinByecadpYWZAnhJiEXyVCn 7QAw== 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=Cn49+pUTSndv14aPb88ANIXCQdyF64j6j67OxcotbKM=; b=ucelsedL63r27yac4DVcA3CWYfffZZeeDmovlsqhjh04Sa/x6MgwEPx195HfH8qW9+ zr0E5XpA5BBIoQd0rn6FrA851IymaDId/+bjYKRzc9LfdXeWdzdGedh00M7SfOpcpm2M 2u6Z2sJYVKgTEBZj01Ww2vfKVXc+vJA3tSZHEPi0+Wt6fmyRueW1HcuHIq2HRrQzhNEJ ZaeGxreAEI1EjBRrCeNI6uhQfWzUMtlmOP3GOseXYEX233s4fzBYHtbkAQAbq76HOnJ9 9Wv6KU4o3E1RgXT48D5Bv4zgmd4UTMb/NF7GJqhxrR4p05qavR4yFVOpcFdVNUJ4iD9w 2apw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KSwuDCra; 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=pass (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 q7si7732591ioi.41.2021.07.15.11.52.30; Thu, 15 Jul 2021 11:52:42 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KSwuDCra; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239660AbhGOSw6 (ORCPT + 99 others); Thu, 15 Jul 2021 14:52:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:51724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240126AbhGOStO (ORCPT ); Thu, 15 Jul 2021 14:49:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 58C60613D9; Thu, 15 Jul 2021 18:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374779; bh=idGe8S9zZMYTLJ11eds0ZckkKuSOThds4gTjGfiUB3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KSwuDCraEhAnx4uMAVzZNBza6YqsxRqsVCNEJ7ziAx6aOKxhyhhJEMYfFkTOhiurr CV7+OcRfsLER6QEMsNmAF4p2lXS74cu/xVl31hJOXWlFqFomlJr2ndzzr876XydLyP x+s0VxQYCdpJ9pTsQxMcoljnAuN0kp5rrmFpSjUs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Andy Shevchenko , Flavio Suligoi , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 008/215] net: pch_gbe: Use proper accessors to BE data in pch_ptp_match() Date: Thu, 15 Jul 2021 20:36:20 +0200 Message-Id: <20210715182600.033803020@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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: Andy Shevchenko [ Upstream commit 443ef39b499cc9c6635f83238101f1bb923e9326 ] Sparse is not happy about handling of strict types in pch_ptp_match(): .../pch_gbe_main.c:158:33: warning: incorrect type in argument 2 (different base types) .../pch_gbe_main.c:158:33: expected unsigned short [usertype] uid_hi .../pch_gbe_main.c:158:33: got restricted __be16 [usertype] .../pch_gbe_main.c:158:45: warning: incorrect type in argument 3 (different base types) .../pch_gbe_main.c:158:45: expected unsigned int [usertype] uid_lo .../pch_gbe_main.c:158:45: got restricted __be32 [usertype] .../pch_gbe_main.c:158:56: warning: incorrect type in argument 4 (different base types) .../pch_gbe_main.c:158:56: expected unsigned short [usertype] seqid .../pch_gbe_main.c:158:56: got restricted __be16 [usertype] Fix that by switching to use proper accessors to BE data. Reported-by: kernel test robot Signed-off-by: Andy Shevchenko Tested-by: Flavio Suligoi Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index 9a0870dc2f03..2942102efd48 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c @@ -107,7 +107,7 @@ static int pch_ptp_match(struct sk_buff *skb, u16 uid_hi, u32 uid_lo, u16 seqid) { u8 *data = skb->data; unsigned int offset; - u16 *hi, *id; + u16 hi, id; u32 lo; if (ptp_classify_raw(skb) == PTP_CLASS_NONE) @@ -118,14 +118,11 @@ static int pch_ptp_match(struct sk_buff *skb, u16 uid_hi, u32 uid_lo, u16 seqid) if (skb->len < offset + OFF_PTP_SEQUENCE_ID + sizeof(seqid)) return 0; - hi = (u16 *)(data + offset + OFF_PTP_SOURCE_UUID); - id = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID); + hi = get_unaligned_be16(data + offset + OFF_PTP_SOURCE_UUID + 0); + lo = get_unaligned_be32(data + offset + OFF_PTP_SOURCE_UUID + 2); + id = get_unaligned_be16(data + offset + OFF_PTP_SEQUENCE_ID); - memcpy(&lo, &hi[1], sizeof(lo)); - - return (uid_hi == *hi && - uid_lo == lo && - seqid == *id); + return (uid_hi == hi && uid_lo == lo && seqid == id); } static void @@ -135,7 +132,6 @@ pch_rx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb) struct pci_dev *pdev; u64 ns; u32 hi, lo, val; - u16 uid, seq; if (!adapter->hwts_rx_en) return; @@ -151,10 +147,7 @@ pch_rx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb) lo = pch_src_uuid_lo_read(pdev); hi = pch_src_uuid_hi_read(pdev); - uid = hi & 0xffff; - seq = (hi >> 16) & 0xffff; - - if (!pch_ptp_match(skb, htons(uid), htonl(lo), htons(seq))) + if (!pch_ptp_match(skb, hi, lo, hi >> 16)) goto out; ns = pch_rx_snap_read(pdev); -- 2.30.2