Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7421116ybp; Wed, 16 Oct 2019 08:24:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9ThR3JdbtD4U1ynomMjMvxf7lJR5+BwRcEk8Fy8xFDnUhLU/mvwomTzSWcy/VTJbCoi36 X-Received: by 2002:a17:906:5e49:: with SMTP id b9mr40466071eju.255.1571239476640; Wed, 16 Oct 2019 08:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571239476; cv=none; d=google.com; s=arc-20160816; b=izFUIjQ5rSqzSZJzN1mJlX6laG6+hWhkZfq9anNEB3pxUVfVAZl5NHDRUnUdt0jOX4 4ufLuWOuYaTWLgSp+0G6J6raIjqDljYjxTmuN4I6D1E4EAX25gi0qYQw59fLu7Otq/J5 JG7JJA3k0hEZRcWlha+ZnpyrV0lMyA2c/onr2j1KU1I8/+0IBgI6QxYA4TqN4mRMbOd2 dGhrBZvrvW/O5OwyIMRXAmvCSrUPZwAFptqAI46CPUu2hOV1DNl34opjVOEFF0lcTILc 7Y8qG4gJBv/Q7saeDqWgXQ0IjFf7cZOSuxNxihq/WpDHU+B4I0CfxycYmjHXpr9cMAaj 0uFQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dmrMhgpUSf60d5nh3MAEGQy/4z6O1wG97cbLuW1Vm/Q=; b=QgIieezKuqqKhLeS4nIQh6uKNxYzPVSxY63nK956x8Mt/PzZsLCO15Vu8vJS3k0Zn2 cv5rf20J+UikvxHBV+xi4wn7lr3xzPHMIcq+s0QCndEk+NniPMmBKdeIOo3xyYqtaH/H 01GQ2JhXT0J9FlY7+jfANA7j40JYwZbvVVAWEPoLEO2OtLI2K6WJ0yUql3UOZvXe70WS Fb6Vn47RO0zZujk/NWYgU0aFH1UekoxLq7qieLXzOq99DXSivWxXF/iHS6/3YPJ9xHEn 2VQcWpWxQRcRR4zKP41EIkPxBXx4cRLTF6Nl/2sqQixkIFb+aGmNLgyPGGHj2pssbmfm z9GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=Lryg5TbK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si17740336edb.335.2019.10.16.08.24.13; Wed, 16 Oct 2019 08:24:36 -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=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=Lryg5TbK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405195AbfJPMU2 (ORCPT + 99 others); Wed, 16 Oct 2019 08:20:28 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46855 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405188AbfJPMU2 (ORCPT ); Wed, 16 Oct 2019 08:20:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id o18so27754897wrv.13 for ; Wed, 16 Oct 2019 05:20:27 -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=dmrMhgpUSf60d5nh3MAEGQy/4z6O1wG97cbLuW1Vm/Q=; b=Lryg5TbKNuFD1H9KnYSEFIXh7TPiZG5JT6QcacCuclZQ7ucsqtGD2RjLXMfRQNQn11 4H8eWrGeyw6gS2x8zrZV2LRijZHZHDiWAS/WnxWrN5PilX42PAZxtYhpJffHaZ93Q0Xb 5yV952iEPXu5/aHNYguUVK3s07QjWaKL860yK9MwH+R94+/TR/9tWxOOY1gav0+m4s/U lvNZoW05LWMCbBwqgknxmY8ZP4NZTlosLfG3f18WVt4LJYwYzJNr0WPoF+YeGPyAH+RQ aNAel85fvckPLTBuXDBW0+kffLA1BAfpPJuw4dw1Cg57p4zBtdSOr4WtIQnK3hTn9zNn y1oA== 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=dmrMhgpUSf60d5nh3MAEGQy/4z6O1wG97cbLuW1Vm/Q=; b=DtLmcCWMxFmweFHsM0/uqG6h5sRretosPjMr5r0n29BFsW8C5/mGJJ43jAL0AUn4rQ qvELP6xbwJvxf1oLdCLqGfg9/vAlwkqWxVhF7gpC0u+A4vAuWcNjpVKjSzcqVJRLu/GE wctqY5vu1n9iqpEISHFLVSGN2T34jcQg5x7pHb1QehtP4nc2SK6rL2a2Nvr4FPr/gruP 24dUIgCCy+kiEpOQxzl+PnHPg/ysXMPaVLBBoHdsM+0I6ikU3vBuGgNmxKIQjPpAoRHh VYKUMbokKgZKIKusH52Wj6evWaHxYsMhXM1wI8irwy5IsCCjMBQgKxbb9Fpb0vyWV/B0 58pw== X-Gm-Message-State: APjAAAXcKRxHW7pjRzbsnc90OM3PJI8wqh9UBDBMSGsChZMphcPIGqqk mZMOgqgtdzSQW3YFK5iAgaGnPQ== X-Received: by 2002:adf:e542:: with SMTP id z2mr2327859wrm.338.1571228426355; Wed, 16 Oct 2019 05:20:26 -0700 (PDT) Received: from netronome.com (penelope-musen.rivierenbuurt.horms.nl. [2001:470:7eb3:404:c685:8ff:fe7c:9971]) by smtp.gmail.com with ESMTPSA id s12sm26946038wra.82.2019.10.16.05.20.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 05:20:25 -0700 (PDT) Date: Wed, 16 Oct 2019 14:20:23 +0200 From: Simon Horman To: "Ben Dooks (Codethink)" Cc: linux-kernel@lists.codethink.co.uk, Marcel Holtmann , 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: <20191016122022.kz4xzx4hzmtuoh5l@netronome.com> References: <20191016113943.19256-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191016113943.19256-1-ben.dooks@codethink.co.uk> 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 12:39:43PM +0100, Ben Dooks (Codethink) wrote: > 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). In any case, the question arises as to if this has ever worked on big endian machines. > hci_req_add(req, HCI_OP_LE_WRITE_DEF_DATA_LEN, sizeof(cp), &cp); > } > > -- > 2.23.0 >