Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp579357imm; Tue, 5 Jun 2018 00:37:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLEBkV7dFfIt/pwZuJ8NMoR68T9pKDsihD3G7RZKt6erLaRD/VPvx4jTjwy5vuoHLrlreD1 X-Received: by 2002:a65:5183:: with SMTP id h3-v6mr19497788pgq.58.1528184250258; Tue, 05 Jun 2018 00:37:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528184250; cv=none; d=google.com; s=arc-20160816; b=OBUvEjpe++YE6rozAGHsVlShuqmvPHU6VYYtgCVRtnRcDue8GDLAfiJNtyB6i8Q3CG upp8FvH4/+Xnjo8Fvs5mkOGPDlNdCACOAwCf5ihC+sSzwuMctu1LadtCZ/V10mTNgg62 eWInX56HmrhxSQV5wW1Iu9f6CK3FTeoAsWUI6LROiCL+dp8DU4ICfQCrihqWUZyIN6lz ygs8VmCgzy8WvIsLmOWmOBcLDBydBQH7gNRQBs6UB0eK064f8eyWt6wRnP5AM4qCl4kQ n1m6kVTWVBchO6FF/vpcubdrDCXcRDc2CydqdzU1eXj3xx+Y6narRoPArPx0sAwjv6uN 5peA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=Ab19qmKc3PaAPa1fCxXPknnKUsaeDXiRhcKB2jiSZbI=; b=B0lqsh3n1uh/qA99RUE1EP8TwSq6q+1BLjxRCi+nycLWeJub89e3jOsci1yAtW9n9Z Ci1Y4JZ+Lml46+yagJY/D49q8AkoqKtwmklEDrAbAGIhnynA1MZvvGcN35vFZsgr5BC1 CJPwUwgj8Vm59c62s3g3e/bu16EJu2KnOkSLG9kbmx9NJ1WGomfZOR83NXJMUeNLS3DR vV0oTiL4OR44JI3ZEPfJ5IG4xMV1wTCeqy37+5Qj1u1ptx/Zi+C6Pq9YCk5pQSCcmxx6 8C4y77uwLMpOiuua4aDnt17aSBZSGjyqXgE1quO6xay+5nHTIzIGEXlZ0NK+EpRYjHln ZRvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=VGjPve4q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z31-v6si48600090plb.200.2018.06.05.00.37.15; Tue, 05 Jun 2018 00:37:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=VGjPve4q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751570AbeFEHgt (ORCPT + 99 others); Tue, 5 Jun 2018 03:36:49 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:44516 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751449AbeFEHgr (ORCPT ); Tue, 5 Jun 2018 03:36:47 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w557a0QB009565; Tue, 5 Jun 2018 07:36:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=corp-2017-10-26; bh=Ab19qmKc3PaAPa1fCxXPknnKUsaeDXiRhcKB2jiSZbI=; b=VGjPve4q60qswmDh4I8W1saNkLat45Q0O9ElOiTo2kqCJcDPP9Z2P5knBQEMK9azKUXx LlcEIDYNYoBmroVj0OHnugXOyKq77LKUUFKnbxQyYWFKYEFpm38B5XjXD27RNpDMmcvA nQeA6JbBY2K6gJueZrdijS1hLwvJCbA0XWVbt4kS+jdG2nrnqKfdfFD5RKoiKGr4qOTw /lJFiys3uzPpCN06r2Bf3T9pRU113nsPNQzNRNcgVhMgq6YNQo+GmxbL0zPIQGfM35tz Ia+ionhhmhEz3v0Dfv0BiqL/1WR/vLOpzpS2eeX6HCqyhsEyTox6cxRyC+AP6ghCNfjM 6A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2jbvyp6v9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Jun 2018 07:36:42 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w557af66011972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Jun 2018 07:36:42 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w557afwE022330; Tue, 5 Jun 2018 07:36:41 GMT Received: from mwanda (/41.202.241.46) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 05 Jun 2018 00:36:40 -0700 Date: Tue, 5 Jun 2018 10:36:31 +0300 From: Dan Carpenter To: Thibaut Robert Cc: Aditya Shankar , Ganesh Krishna , Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] staging: wilc1000: fix some endianness sparse warnings Message-ID: <20180605073631.cvp2iuef4yb636jz@mwanda> References: <20180529191143.13081-1-thibaut.robert@gmail.com> <20180530111725.gmigyddsp2i6mgzw@mwanda> <20180604193250.GB32753@L80496> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180604193250.GB32753@L80496> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8914 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806050093 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 04, 2018 at 09:32:50PM +0200, Thibaut Robert wrote: > Le mercredi 30 mai 2018 ? 14:17:25 (+0300), Dan Carpenter a ?crit : > > On Tue, May 29, 2018 at 09:11:43PM +0200, Thibaut Robert wrote: > > > diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c > > > index e248702ee519..745bf5ca2622 100644 > > > --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c > > > +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c > > > @@ -1431,7 +1431,7 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) > > > > > > freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ); > > > > > > - if (!ieee80211_is_action(buff[FRAME_TYPE_ID])) { > > > + if (!ieee80211_is_action(cpu_to_le16(buff[FRAME_TYPE_ID]))) { > > > > "buff" comes from the network, it's going to be little endian, not cpu > > endian. The rest of the function treats it as CPU endian but I'm pretty > > sure it's wrong... > buff comes from the network but we are looking at single byte here. > ieee80211_is_action expects an le16, so we I added this to extend an u8 > to an le16. Is this incorrect ? > > Or maybe we the buff has the second byte ? but that I can't tell. You raise a good point that I hadn't seen. The original code is clearly buggy. But your fix isn't correct either... The other thing to consider is that cpu_to_le16() is basically a cast to u16 on x86 so it's a no-op here. Really the right thing is to not treat buff as an array of u8 but a struct. The code assumes that frame_type is 0-255 but probably it's supposed to go up to U16_MAX. struct whatever { __le16 frame_type; ... There probably is already a struct like that, but I don't know what it is. I don't know this code at all, I'm just guessing. regards, dan carpenter