Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1006058pxj; Thu, 17 Jun 2021 19:58:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwNjno6ouaXyb041U9VF9eRm1+W2Zrk7XYTjeSG8NGn/maLOiDbf8UmkLMySxkP1dNJpwk X-Received: by 2002:a05:6402:498:: with SMTP id k24mr1955286edv.2.1623985123408; Thu, 17 Jun 2021 19:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623985123; cv=none; d=google.com; s=arc-20160816; b=r6PEelShTFZVd4IRuMvESDYETUWA/s31tZ4P6h9LfiQ7ZamcBFApojlzlmzb4Mgg7l 82Ibc+CQvf7EhAHTMqG6aXrl2wayRrP0oNRePDmHWq1We5HjKLYFMsuc7F3/YLISbuhV Opz3guwgqhsCs9JFucZC9ifFN3S6eIv2JATO8TD4uKNAOWudZ337TEqJgJPIouA8Rk/T qJRIXndg1KmCWZvjgWa0XoMT+bueZWXFgckeWQeykif0dv4ngbW31UG0TVPisiqEDTmw 8HG9WhcMPTiwIcef6CuOztwgKXmYayf2k7O82cocxOjhv407TNeGo36wZ/yDYTIrG5JD yzkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=WwGN40wY9I8THhgsShLHrJQkEXTDaaD9iCeo7F3j9AE=; b=yMsYzW3SAzezLEGTU8dEcxeva+zg0gGpE+GaUM8b9cS2dDqaKGmMwD6H7MGX9QOmZU W0AAmF97gDL0loanGDScElWDTKSZksR71j8MjMosrmsUKQ2n697TFtBkYOZGx3EMy3OQ jZ5QPGTGNQf4toKMIJrf0ovIvZOHSAreRHPK91DJlyei8Nu4pUTmfW9hTd1NE31tMqCk ddgPdqAiKoeGQ3PVv4sdwDjMTUzQz2L2pWcC14UWlZFeCHf0oZKQdtVoWaByHJSIOQzC 3ZS8THAfRWGT4MItkQWvC9ChlYFW0ZWmxeMkk6zJ/wSK4LYasqqs8vqaB95kEwju0V/s Y0Nw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si1024901edj.569.2021.06.17.19.58.20; Thu, 17 Jun 2021 19:58:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232553AbhFQXqa (ORCPT + 99 others); Thu, 17 Jun 2021 19:46:30 -0400 Received: from netrider.rowland.org ([192.131.102.5]:45077 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S230447AbhFQXqa (ORCPT ); Thu, 17 Jun 2021 19:46:30 -0400 Received: (qmail 296032 invoked by uid 1000); 17 Jun 2021 19:44:21 -0400 Date: Thu, 17 Jun 2021 19:44:21 -0400 From: Alan Stern To: Greg Kroah-Hartman 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: <20210617234421.GA295854@rowland.harvard.edu> References: <20210617162755.29676-1-ruslan.bilovol@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Alan Stern