From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6A80FA3735 for ; Thu, 17 Oct 2019 12:43:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77EAF20869 for ; Thu, 17 Oct 2019 12:43:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="1W6T+By6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406480AbfJQMnF (ORCPT ); Thu, 17 Oct 2019 08:43:05 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45742 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392868AbfJQMnE (ORCPT ); Thu, 17 Oct 2019 08:43:04 -0400 Received: by mail-wr1-f68.google.com with SMTP id r5so2158823wrm.12 for ; Thu, 17 Oct 2019 05:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=HGYfQMOQQ/Llw7JM+7jrZqk8jvWFbqivJs1N/X/ktYU=; b=1W6T+By6Fyb2jmC1zIN29lxvN1RfimvyqGZm/IyNd0V+jAhEnMuR3HyZpQgzrmOhLk PVRFTAfV/ZKXqr6U/08O1Ez3u3mVXh5UF45EOmJyN3i4IzE3ozHnHpbxebhjZ94shBvL gHXflbn54dpLGUVRAM6N1AIiKogkN2aPAmJCtXER0fMyKruwAyjCtnCp3Rdk4VX76zV8 vxUCyNaqnutYi9qbxamM5qop4YUgQPt/9Tt21OPAYxz34RRWnzsq5SkxwtK6D7YJZOTA WmDUDbMaLCyxAVbKdVFhHQMpTO7XA2cyDMEkk1fNYHBI9fnGNSx8oQhGeCqkQaUCwJaf ML8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HGYfQMOQQ/Llw7JM+7jrZqk8jvWFbqivJs1N/X/ktYU=; b=BHsP6UtNSXG2SM2S3o3FRygrzRkeXsIemKMgjyT8R9wckQYfqHbR1zjOEEQ+Lhfs+V /UqiGG8Rp2x9zB/ue6UTw3FpMnFbgCVtLH4PRSB9FqRXsefxEAnby3KMCGWL7lXAVEoO 9F9fSRcaq4dMjHjRuiANpLfyXl0kjUBQoqNOvq8o/xVyq/KMemIGMIoqHivj7HJX9oQP 3gxql4yjK2UZAfbyJqnzEHzXgZKlFeIogMJj/RWVsXni/TFZxEzFPccjY1EPxuHdSjlW IooDDmRfhhUN6fWZjl08qkxhMI7Q/CaLbp/FbmOyVms+HDolQwxxnt2MgNCCTr7SNR1Q u1bA== X-Gm-Message-State: APjAAAW17O2PVw6DaEI7sLJzBqGCTwZoiY3GodHq5glfgoj5v9S7sCsM DlnmGK38ghi5xk0xiM34VpggzQ== X-Google-Smtp-Source: APXvYqxSTrTbdDOJVZ/NSpsLlPLKMh5bomXVvJWF0PlOY6wiEaCsHR6FF/GB5VdIRYS1B4NMgrdXsA== X-Received: by 2002:a05:6000:1190:: with SMTP id g16mr2819078wrx.133.1571316182250; Thu, 17 Oct 2019 05:43:02 -0700 (PDT) Received: from netronome.com ([2001:982:756:703:d63d:7eff:fe99:ac9d]) by smtp.gmail.com with ESMTPSA id k8sm576756wrg.15.2019.10.17.05.43.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 05:43:01 -0700 (PDT) Date: Thu, 17 Oct 2019 14:43:01 +0200 From: Simon Horman To: Marcel Holtmann Cc: "Ben Dooks (Codethink)" , linux-kernel@lists.codethink.co.uk, Johan Hedberg , "David S. Miller" , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] RFC: Bluetooth: missed cpu_to_le16 conversion in hci_init4_req Message-ID: <20191017124300.fktzd27yy2t7gcqx@netronome.com> References: <20191016113943.19256-1-ben.dooks@codethink.co.uk> <20191016122022.kz4xzx4hzmtuoh5l@netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 16, 2019 at 08:42:48PM +0200, Marcel Holtmann wrote: > Hi Simon, > > >> It looks like in hci_init4_req() the request is being > >> initialised from cpu-endian data but the packet is specified > >> to be little-endian. This causes an warning from sparse due > >> to __le16 to u16 conversion. > >> > >> Fix this by using cpu_to_le16() on the two fields in the packet. > >> > >> net/bluetooth/hci_core.c:845:27: warning: incorrect type in assignment (different base types) > >> net/bluetooth/hci_core.c:845:27: expected restricted __le16 [usertype] tx_len > >> net/bluetooth/hci_core.c:845:27: got unsigned short [usertype] le_max_tx_len > >> net/bluetooth/hci_core.c:846:28: warning: incorrect type in assignment (different base types) > >> net/bluetooth/hci_core.c:846:28: expected restricted __le16 [usertype] tx_time > >> net/bluetooth/hci_core.c:846:28: got unsigned short [usertype] le_max_tx_time > >> > >> Signed-off-by: Ben Dooks > >> --- > >> Cc: Marcel Holtmann > >> Cc: Johan Hedberg > >> Cc: "David S. Miller" > >> Cc: linux-bluetooth@vger.kernel.org > >> Cc: netdev@vger.kernel.org > >> Cc: linux-kernel@vger.kernel.org > >> --- > >> net/bluetooth/hci_core.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > >> index 04bc79359a17..b2559d4bed81 100644 > >> --- a/net/bluetooth/hci_core.c > >> +++ b/net/bluetooth/hci_core.c > >> @@ -842,8 +842,8 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt) > >> if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { > >> struct hci_cp_le_write_def_data_len cp; > >> > >> - cp.tx_len = hdev->le_max_tx_len; > >> - cp.tx_time = hdev->le_max_tx_time; > >> + cp.tx_len = cpu_to_le16(hdev->le_max_tx_len); > >> + cp.tx_time = cpu_to_le16(hdev->le_max_tx_time); > > > > I would suggest that the naming of the le_ fields of struct hci_dev > > implies that the values stored in those fields should be little endian > > (but those that are more than bone byte wide are not). > > the le_ stands for Low Energy and not for Little Endian. Thanks, in that case I have no objections.