Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp420427pxb; Thu, 19 Aug 2021 02:45:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMZTr4qe45mYNPWGc2/a8Cyabpp2C1HV9F7qk+3i8Zj50jaDqrqw9nLAhaEBLofQg5YCfm X-Received: by 2002:aa7:dc56:: with SMTP id g22mr15592500edu.129.1629366354400; Thu, 19 Aug 2021 02:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629366354; cv=none; d=google.com; s=arc-20160816; b=seU9ifUQh3BW62Z8TLob2nXDNVEmB2xrh5rsYTfpLyAp0jL1QQondSxuDiZZBBBhiY OvLfTvGvSxPoyu4Z3LBHTO7TW8c1vXYrhpEEWXgHilPI3AHKo34ZWe07NTDqyhfnUSjR SjSh+JT2uCPSGcTM4HXlbhvNCBFY3OJDJz8++EpAwcYJh3OX0OcW8B8rs9sjp7nlC/5A 9kTotAmDPbvFyZcLTK1BpYaTDwcPqm6n7avKz0LKGT9VJuChx8RyNA9hcYDgYWWXeBbJ 16k3zyiddC9nWfm1jIkKQe8kzyq9uo4mLze6NHzuuD7/Fso/WJLpuu2rl6maYYHwZ6h/ aDMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=mDQiWmBrQikS74WVmGm3Ud4Z5ZSnq7L1Utp9j7wMwwk=; b=SQGgM1sCVw5KtmTazn8lwJmzcuYsAVFbtkCj8i/pfnTNFGWrIbgaHD19VwwGPyCRZd 5ojvXT1nezgsX9dsentcHnO7DrgAqTbgUxhMol0KAOFOV07yHyd6ltYJ+EQWhKhzB6uO eK7ZVGf7qV92uBIeJ6xUQRetUo5uknbht2c6d3Me8DWN7XqICXsoayqmxSyHMX9hifz4 Wngl2/B4YVY1skhLPsG7ACVYfDxU8ilsC6RWP3iUKfI6jivaiBlISxBIS5wD7DlhII3K vnOMfUlq1RQBNP9rT6keMk2YgrSTiMdagtK94sKraqOZU6XeALegMvShk9qgI/9G7veV OUtQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si3716013ejo.390.2021.08.19.02.45.29; Thu, 19 Aug 2021 02:45:54 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237652AbhHSJoU convert rfc822-to-8bit (ORCPT + 99 others); Thu, 19 Aug 2021 05:44:20 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:25556 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237583AbhHSJoT (ORCPT ); Thu, 19 Aug 2021 05:44:19 -0400 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-25-tzJRfeh1Naq-lFeOcnhxig-1; Thu, 19 Aug 2021 10:43:38 +0100 X-MC-Unique: tzJRfeh1Naq-lFeOcnhxig-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 19 Aug 2021 10:43:38 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.023; Thu, 19 Aug 2021 10:43:38 +0100 From: David Laight To: 'Aakash Hemadri' , Greg Kroah-Hartman CC: Shuah Khan , Bjorn Helgaas , "linux-staging@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32 Thread-Topic: [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32 Thread-Index: AQHXksUjJhmKROZmZkOAch25AOXZzqt6ltFA Date: Thu, 19 Aug 2021 09:43:37 +0000 Message-ID: References: <1be80f0196bed681bf55bfe3155f564b4ebf3b76.1629135143.git.aakashhemadri123@gmail.com> In-Reply-To: <1be80f0196bed681bf55bfe3155f564b4ebf3b76.1629135143.git.aakashhemadri123@gmail.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aakash Hemadri > Sent: 16 August 2021 18:35 > > Fix sparse warning: > warning: cast to restricted __le32 How many different copies of this crappy copy are there? > ... > diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c > b/drivers/staging/rtl8723bs/core/rtw_security.c > index 381deeea99d0..5320b1a46dfb 100644 > --- a/drivers/staging/rtl8723bs/core/rtw_security.c > +++ b/drivers/staging/rtl8723bs/core/rtw_security.c > @@ -122,7 +122,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) > arc4_crypt(ctx, payload, payload, length); > > /* calculate icv and compare the icv */ > - *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4)); > + *((u32 *)crc) = ~crc32_le(~0, payload, length - 4); You've removed a byteswap which is needed on BE architectures. > } > } > @@ -621,7 +621,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) > arc4_setkey(ctx, rc4key, 16); > arc4_crypt(ctx, payload, payload, length); > > - *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4)); > + *((u32 *)crc) = ~crc32_le(~0, payload, length - 4); > > if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] || > crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) As above - crc32_le() does a 'little-endian crc' but returns a host-ordered value. The (horrid) array cast means you need to store a LE value. There are a dozen better ways to do this - I'm bored of quoting them. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)