Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp641271imm; Tue, 5 Jun 2018 01:54:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL6R0QL6IklZr8cQwNjfewTcxAgWwAp6eQks+68CInItCISlUK10WAi3HEhNE37alQVP5q3 X-Received: by 2002:a63:40c7:: with SMTP id n190-v6mr5898264pga.248.1528188856747; Tue, 05 Jun 2018 01:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528188856; cv=none; d=google.com; s=arc-20160816; b=y2Naut0WmRm8k9DdhdmrCjpB11b5bdAgw2zux/ihA6D45AHhZ6JvpSp6DBWI2/zSG8 H8MezT6NoxXlJ30fbI+09Afr+qtdNQRSFrdgqsSxU52VVQsqLIUcgTxZsUVOrJ0+P7MQ w3rP77TFCqQTO3o0LOpWByLHf+oEMYRIsAXordV4lJ2buitEaOz7FwbZ/h1gCxtGg9zS xlOxurG6fQy8Xp6VljNZtG6ZeG5ePBnMiJyWkYWSu9gD9tdm8vRYvYqiHgzMZiNyNGax ukJyC/8iz4l5l+68tOqgaKKlN+M2nRMUO6dF99ny+Lr2z2Xrela7hqKlfyBLwhBynzpn TaQw== 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=FwrZ9awUkt60o8sqPLKmfXkPkqkCNPP299Zg5m4miKs=; b=C4LFAgPcvLgtuUyMM7pi+Mpd4lRGTwDlWspMohxFXzKhUVAEtdqGXnzhEQp+8u+lNi ysIQbb3rQ4/U3NDHqADPBLcwBTfq9fbfMay5dresNHdxRtyOQtlv54pI4t9ByNoVrs2Z q2YmDNMbemiFs6spyWNrPAOBtQIk1xaqiC/WEegSczyUFRCSjkNb1Y57dpMcOjmydCxL 3FHd3JzXP/c9cubzvpO1lriq0kFuxFmSm/8iNYNIlGEI0dt2Jb4scpxu7VPcWkVU7t62 974wIrjvbdzIsYq84flbzXEjVGczMSBeZ9YezBsipuFXNpay1yTOfrO6gDFJ/CzbpnZJ XtUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Jeh3ekUm; 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 k28-v6si15986942pfh.50.2018.06.05.01.54.02; Tue, 05 Jun 2018 01:54:16 -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=Jeh3ekUm; 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 S1751735AbeFEIxZ (ORCPT + 99 others); Tue, 5 Jun 2018 04:53:25 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58302 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbeFEIxY (ORCPT ); Tue, 5 Jun 2018 04:53:24 -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 w558p2Ua067572; Tue, 5 Jun 2018 08:53:19 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=FwrZ9awUkt60o8sqPLKmfXkPkqkCNPP299Zg5m4miKs=; b=Jeh3ekUmUqRbCqetyjXXqYI6tX43SeR5jEWbixm2n472U1Kp3ynezzCX0kyZ4YxRG4Hb TfsJSi2SZNlbx2Rj3BiJIQZ8cpfVNql+7OSrvJEFaKTRvYd0GdJTncXr3p7iPG8CbJs9 tRQOIRAnEJmfXPOd2/OYnyhkE+XRHOWszUzQvQCGXTWwG/WnO4UjFLba+BYKS6dadgWg FK5/c2jUxkWUSwuaSEEcAUSjs9IK+VzTakHXl3d+OnXqiMeLZ48EXc+spqrOJwbtqczy 81Kv3xh4ja8WokyWPf56r2Ez8Ipx+0FL9In6Q6EAPSg+9QW0yWzHNAMYRFqfpQKr16EQ 3w== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2jbvyp77g5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Jun 2018 08:53:19 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w558rJZF024601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Jun 2018 08:53:19 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w558rIKT030784; Tue, 5 Jun 2018 08:53:18 GMT Received: from mwanda (/41.202.241.46) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 05 Jun 2018 01:53:17 -0700 Date: Tue, 5 Jun 2018 11:53:04 +0300 From: Dan Carpenter To: Thibaut Robert Cc: devel@driverdev.osuosl.org, Greg Kroah-Hartman , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Ganesh Krishna , Aditya Shankar Subject: Re: [PATCH 1/2] staging: wilc1000: fix some endianness sparse warnings Message-ID: <20180605085304.jycb5l3gomwlujq5@mwanda> References: <20180529191143.13081-1-thibaut.robert@gmail.com> <20180530111725.gmigyddsp2i6mgzw@mwanda> <20180604193250.GB32753@L80496> <20180605073631.cvp2iuef4yb636jz@mwanda> <20180605083325.GA6965@L80496> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180605083325.GA6965@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-1806050108 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 05, 2018 at 10:33:25AM +0200, Thibaut Robert wrote: > Le mardi 05 juin 2018 ? 10:36:31 (+0300), Dan Carpenter a ?crit : > > 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. > The sparse warning is clearly spotting a real issue. I tried to at least > have big endian handle correctly the 0-255 case. I am willing to drop > the change (since I agree it's not very satisfying and will mask an issue), > but may I ask you to explain how it is wrong ? How would you correctly expand > an u8 to __le16 ? I think in big endian we need to swap the bytes. You're right that on big endian we would need to swap the bytes and cpu_to_le16() does that. regards, dan carpenter