Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp330428pxb; Wed, 13 Jan 2021 04:58:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1oWAY6m+LWYnZPguw0YX3h3u6QWTqs0tPZqmVAugl1gq7JBHvakpPq9kEFUT0AYdl3/5w X-Received: by 2002:a50:b5c5:: with SMTP id a63mr1676855ede.227.1610542688569; Wed, 13 Jan 2021 04:58:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610542688; cv=none; d=google.com; s=arc-20160816; b=EgEA7nsmd0C3o+4XPqAAr5Qye7Cy7FwtMu8iU+KjgncFHWoR7q2SkejRxIYn6A54Y5 a5lSflQguXIKXW5WU3c/wrGUFdmmdF6dBJIXIdphKqePjUC9bJy1utdLwSZORFcgREjD o1VzRbFASTQeHmngc0TEJP8vH6GjF7UG/tiy8OwHhZrenui3mhl6GGC3MpkxbbFnjlp4 Sa8Vu19wyW1bwQ61v/KcTatfE0dwJusD2jf561xH+aUqABuzgAUaFfoMjeHkmcLnY4KJ xo+G/IZ6TsXnB6VGRSgPFwMFPRCmB9nyxnAAvf8p2xuHjDtnCFqOdQozZDUWAE/3fODI azYw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=x4MEzZAidjLHW40Tp5zaGtKFU83yiIF3ECWN6MYMpno=; b=gL7NFAHD15zfvc2ZIGQtXBLjZINuMZF2K8cr+V6scVJ/AkcyovDsJT+XI9n1O/7RVG p+ACTzO7lqWK2HeHeuH4MxuKSN7p++Yp3S1CiATybQvVqss5WkHclTuvHcWBOswyH0F9 oWkuzYvknjFdYRTJKAEiM6NyG7xtFkmizAgEseCMVkL8eDX0xkubmrVd8tsvVWsy+4Jb DiAkKZOD9ZEs4nGYL5c6W0OEgZyfyanB/cWFQvqh9JJpFmlkuNAiCZGUXOkBWbjEvYJx efaCCafWut7DRTrltJ23cwZVTYyjPv5f7eatOsrp64j8j/B1wjW8lpIKNVrEwTvFcHiH iJow== 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 f2si931011ejz.310.2021.01.13.04.57.45; Wed, 13 Jan 2021 04:58:08 -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; 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 S1727402AbhAMM4G (ORCPT + 99 others); Wed, 13 Jan 2021 07:56:06 -0500 Received: from mail.savoirfairelinux.com ([208.88.110.44]:39128 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbhAMMzu (ORCPT ); Wed, 13 Jan 2021 07:55:50 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id B5F3F9C0DCC; Wed, 13 Jan 2021 07:45:46 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id SjBZ2rqqZ1J4; Wed, 13 Jan 2021 07:45:46 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 5F3D49C0DD6; Wed, 13 Jan 2021 07:45:46 -0500 (EST) X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xge2FfEn1AmX; Wed, 13 Jan 2021 07:45:46 -0500 (EST) Received: from gdo-desktop.home (pop.92-184-98-96.mobile.abo.orange.fr [92.184.98.96]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 68CE89C0DCC; Wed, 13 Jan 2021 07:45:44 -0500 (EST) From: Gilles DOFFE To: netdev@vger.kernel.org Cc: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Subject: [PATCH net 6/6] net: dsa: ksz: fix wrong read cast to u64 Date: Wed, 13 Jan 2021 13:45:22 +0100 Message-Id: <28e0730f2bdac275384fac85c4a342fb91f9455f.1610540603.git.gilles.doffe@savoirfairelinux.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org '(u64)*value' casts a u32 to a u64. So depending on endianness, LSB or MSB is lost. The pointer needs to be cast to read the full u64: '*((u64 *)value)' Signed-off-by: Gilles DOFFE --- drivers/net/dsa/microchip/ksz_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/mic= rochip/ksz_common.h index 44e97c55c2da..492dcb2011f1 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -213,7 +213,7 @@ static inline int ksz_read64(struct ksz_device *dev, = u32 reg, u64 *val) /* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */ value[0] =3D swab32(value[0]); value[1] =3D swab32(value[1]); - *val =3D swab64((u64)*value); + *val =3D swab64((((u64)value[1]) << 32) | value[0]); } =20 return ret; --=20 2.25.1