Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5627731rwi; Sun, 23 Oct 2022 09:07:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XX8UCfI55eRHJplMEqNy3F3hwIreGzHWGejmilbR/qKZSJnAyZj10q6Kxx3GOg32dNPhW X-Received: by 2002:a17:906:3019:b0:7a7:6425:7d1e with SMTP id 25-20020a170906301900b007a764257d1emr1224714ejz.663.1666541238976; Sun, 23 Oct 2022 09:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666541238; cv=none; d=google.com; s=arc-20160816; b=v7zFCzJvEnyqX74S+DBgSoToTq1NSkpVIl6eWKaL27gNJGza0NzJtRYd/z/OlbYlCA LAAZ1bgUkZ3VdILMr/3Fx1fUlslg/A1dyBhZJGqb6TcLS/F4MyuXeRmrr/D47gCK6zws 7ApB/R8ca4XaCngf+pQTDvahQ5mSecrqtBcrMa9eURmGODcHZ2SuH4zQIvHsvZp1cZCo T/0iE8pVScWvMeJliI5FafaKPN/m7U75iFsUq1+cmXzfDzB1pu0iq6Kt3+7HsFkuhPYT B5+Cj/LjjEGc9W5tan7br+R2QsGRP3Pq7oxYb7DTkaM2FGZ2m9YS9Od+fqvGjERqieMx vLlw== 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=+eapOen4fbjzlHyGiNLED5mC5Axrx4FMUr5BtGYVWEE=; b=IdOyyfe62Bv1bF0CgHcpqx4JaOsejYNqZrG/et+nsfvW19Q4XwWBBEKl8cwHyFjam0 q4MfW+vbgoor+HS9Ik7GkYAV2coqaTqekOXA3AXgwuRIHfq/C8GDlvon0B4vzjXdTVrz iXTVKcsLSskRxqyPXG3b5yFcX39nAhvZPj1ZnETCSNYZ7yG0XdoGqPVt5o/UNCSsBQbM bVoSi+RuqRppEU4QalPmc2046qHjVAhx37+Df+47wETQo/d23Dq+4DByFVguXNMjrSUA Z82Edh4EzuXNA11Vzd++C+lYPU4FpNR0e8HtqnUd4E2s3PHXCNqymS4rNpFV6GKVA09Y NjPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YOrt6Jzq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a1709063d5100b00781df60a2c8si20441274ejf.342.2022.10.23.09.06.51; Sun, 23 Oct 2022 09:07:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YOrt6Jzq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230301AbiJWPxZ (ORCPT + 99 others); Sun, 23 Oct 2022 11:53:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbiJWPxY (ORCPT ); Sun, 23 Oct 2022 11:53:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DE5B26ACD; Sun, 23 Oct 2022 08:53:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9C6BE60BC2; Sun, 23 Oct 2022 15:53:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50BAAC433C1; Sun, 23 Oct 2022 15:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666540403; bh=ekK4EkWfWOMVR684/LcQ4fMn38h47MS8KHYwWM+PKgo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YOrt6JzqRmT1xmvsjzceT7jUFDpFfSmFcpmI8z4M3McDifaEytLVrCQd3xwNU83Fz B8K0W8248/16bs2J/C+RpCB5GFs8KBMWfF+yaVFiwr1ctinT60/wBuCSkmI7eep7IY 1NLtfQPRdLWfyphYMVjZ8yKQuomy1pjQFy4E+/pA= Date: Sun, 23 Oct 2022 17:53:19 +0200 From: Greg Kroah-Hartman To: Linus Torvalds , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , Jakob Koschel , Randy Dunlap , Ira Weiny Subject: Re: [PATCH] USB: gadget: dummy_hcd: switch char * to u8 * Message-ID: References: <20221021064453.3341050-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 21, 2022 at 10:30:37AM -0700, Linus Torvalds wrote: > On Thu, Oct 20, 2022 at 11:44 PM Greg Kroah-Hartman > wrote: > > > > The function handle_control_request() casts the urb buffer to a char *, > > and then treats it like a unsigned char buffer when assigning data to > > it. On some architectures, "char" is really signed, so let's just > > properly set this pointer to a u8 to take away any potential problems as > > that's what is really wanted here. > > I think you might as well also remove the cast that was always a bit odd: > > buf[0] = (u8)dum->devstatus; > > although maybe it's intentional ("look, ma, I'm truncating this > value") because 'devstatus' is a 'u16' type? (adding Alan as he's the owner of this file now) Yes, devstatus is a u16 as that's what the USB spec says it should be, but so far only 7 of the lower bits have been used. I guess to do this properly we should also copy the upper 8 bits in to buf[1], eventhough in reality it's only ever going to be 0x00 for now. Although if we ever do get another 2 status bits defined, this code will break so we probably should do that too. I'll go do that for a v2 of this and properly comment it. > I suspect a comment would be more readable than an odd cast that > doesn't actually change anything (since the assignment does it > anyway). > > Or maybe people wrote it that way on purpose, and used that variable > name on purpose. > > Because 'dum' is Swedish for 'stupid', and maybe there's a coded > message in that driver? That whole driver is called "dummy" as it's a "fake" driver, not a "stupid" one :) thanks, greg k-h