Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3601332pxj; Mon, 21 Jun 2021 02:24:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT2ZSWACf0kma/sv1Jzup2TuxaCVEgdyuhEF7rHYzeLs/w31fZ/nuG7HNa9MWn5FbWZ0IH X-Received: by 2002:a17:906:4b15:: with SMTP id y21mr23420260eju.261.1624267449951; Mon, 21 Jun 2021 02:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624267449; cv=none; d=google.com; s=arc-20160816; b=c5Tm94DHdeAse4a5iF73mZ/5Wy5GgpeN/+bHA6UhXOsrwtVF+noaiArrUlkCHfwUCq h8MQ8xCE/cGS4ziU5MNMMZ4HYT+TJ+WnKZXCFNjfUVZKkt+wACJetfsynQseD/2MQZ2Z O4kRf0Y8yZbe62Uj4MX2WyI0e/ZDT+yVYKsWsiHQAkmOJPcf6NbjmX5d3GpoTvB9YprJ 99fFY78neSVP4N3VsEApuMgRjhrMTonl5YpePMnL0gjA+msUxwMvVl96PfXrD+/wno8Q KWVv1DwDIQgfAJad0VJuDWk7kZuORFahqWpQCVyqPhzBdvCSILezclTT4fC2ZKfcriT7 Elvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uCJnli52KPU81ttuqm1xmAmDE6SqGNyPiBhzUXZU21A=; b=SOBjM32U8c27SToyXZdQHrdQt8ccnKm/3MY2f507+Nsc+LSlWDWvUBP/qQQgwZa0B5 Tt+VfIqeOfdeWquTpSkbDvoTMi9uXB37uE/HL2SyGKrcMdEih/u15/wU7Pj+lEE91T9l cFom2xdbSnuqmeGkx24Phh8XI72WquAKrhD7OyJlzkwUjtYQlcY158FKxruB9edUZGfD W4H0icKfnd0iRhh978sGMGpDu+jz3gp7aqvxE3VwfLUi6+w1yCvg6Z6nD7n+IfCy/I02 gPjagfG01/Zqwej5RC6hM1YGPfXO6CKK4QC6Jp5/QcwuFg83o9P3dsXQMcI/BDImCShV HD1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=klRlPDCa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d25si12423234edx.409.2021.06.21.02.23.47; Mon, 21 Jun 2021 02:24:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=klRlPDCa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbhFUJYz (ORCPT + 99 others); Mon, 21 Jun 2021 05:24:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:45432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbhFUJYy (ORCPT ); Mon, 21 Jun 2021 05:24:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 23FE261002; Mon, 21 Jun 2021 09:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624267359; bh=7nH7mh7nw4aBeDVanu7wJ25k1fGBowCozGKRrUJTO9Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=klRlPDCar6MsklKGuq5Jeog4PvJP80d0xihaELpclU7T+Kd2CM3WjPPEUNOkcJ7ks ShLQYFBp61AMiiDVS+ZuROCig05qjflnH7vEy40VIvXRSusEi8bHrlOJBVFF3ix+Fq 19vG+QuUnzSQBFJCJMNV66ZaeNh55VTzV8t3Edz8= Date: Mon, 21 Jun 2021 11:22:36 +0200 From: Greg Kroah-Hartman To: Alan Stern Cc: Ruslan Bilovol , Felipe Balbi , Fabien Chouteau , Segiy Stetsyuk , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@kernel.org Subject: Re: [PATCH] usb: gadget: f_hid: fix endianness issue with descriptors Message-ID: References: <20210617162755.29676-1-ruslan.bilovol@gmail.com> <20210617234421.GA295854@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210617234421.GA295854@rowland.harvard.edu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 17, 2021 at 07:44:21PM -0400, Alan Stern wrote: > On Thu, Jun 17, 2021 at 06:52:54PM +0200, Greg Kroah-Hartman wrote: > > On Thu, Jun 17, 2021 at 07:27:55PM +0300, Ruslan Bilovol wrote: > > > Running sparse checker it shows warning message about > > > incorrect endianness used for descriptor initialization: > > > > > > | f_hid.c:91:43: warning: incorrect type in initializer (different base types) > > > | f_hid.c:91:43: expected restricted __le16 [usertype] bcdHID > > > | f_hid.c:91:43: got int > > > > > > Fixing issue with cpu_to_le16() macro > > > > > > Fixes: 71adf1189469 ("USB: gadget: add HID gadget driver") > > > Cc: Fabien Chouteau > > > Cc: Segiy Stetsyuk > > > Cc: stable@kernel.org > > > Signed-off-by: Ruslan Bilovol > > > --- > > > drivers/usb/gadget/function/f_hid.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c > > > index 70774d8cb14e..02683ac0719d 100644 > > > --- a/drivers/usb/gadget/function/f_hid.c > > > +++ b/drivers/usb/gadget/function/f_hid.c > > > @@ -88,7 +88,7 @@ static struct usb_interface_descriptor hidg_interface_desc = { > > > static struct hid_descriptor hidg_desc = { > > > .bLength = sizeof hidg_desc, > > > .bDescriptorType = HID_DT_HID, > > > - .bcdHID = 0x0101, > > > + .bcdHID = cpu_to_le16(0x0101), > > > > This is a BCD value, not a little-endian value, are you sure this > > conversion is correct? > > It's a BCD value, but the storage format is little endian. So yes, the > conversion is correct. > > But even more, the conversion is correct because 0x0101 yields exactly > the same sequence of bytes in little-endian and big-endian orders! > Either way, it is two bytes each containing 0x01. Ah, which is why no one has noticed this yet :) I'll go apply this just to be "correct". thanks, greg k-h