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=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 6ED45FA3728 for ; Wed, 16 Oct 2019 18:42:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 519DA2067D for ; Wed, 16 Oct 2019 18:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394341AbfJPSmv convert rfc822-to-8bit (ORCPT ); Wed, 16 Oct 2019 14:42:51 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:52361 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728768AbfJPSmu (ORCPT ); Wed, 16 Oct 2019 14:42:50 -0400 Received: from surfer-172-29-2-69-hotspot.internet-for-guests.com (p2E5701B0.dip0.t-ipconnect.de [46.87.1.176]) by mail.holtmann.org (Postfix) with ESMTPSA id 59577CECDF; Wed, 16 Oct 2019 20:51:47 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3594.4.19\)) Subject: Re: [PATCH] RFC: Bluetooth: missed cpu_to_le16 conversion in hci_init4_req From: Marcel Holtmann In-Reply-To: <20191016122022.kz4xzx4hzmtuoh5l@netronome.com> Date: Wed, 16 Oct 2019 20:42:48 +0200 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 Content-Transfer-Encoding: 8BIT Message-Id: References: <20191016113943.19256-1-ben.dooks@codethink.co.uk> <20191016122022.kz4xzx4hzmtuoh5l@netronome.com> To: Simon Horman X-Mailer: Apple Mail (2.3594.4.19) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Regards Marcel