Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp788207pxp; Fri, 11 Mar 2022 15:08:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaH+koUNTK6Xdql//3kNNA8AI4P810LH/pCX2oh/S5l8Bj7pJhQ4GfbpSK5UJexYLJ8LvA X-Received: by 2002:a17:902:8686:b0:153:28ce:891b with SMTP id g6-20020a170902868600b0015328ce891bmr9017002plo.144.1647040135813; Fri, 11 Mar 2022 15:08:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647040135; cv=none; d=google.com; s=arc-20160816; b=v6MRlzjZnU/xXVwA4z88z5s/vMnDnHyEQAocMOdyfoF9eT7nzU/RWjsoewmtiXumn4 kUQt20VZJfGHfEUepZckY4mGsNyPz8lUoekDsVGJBJQRwW4z4EIGUu+bVwAHb7GvGG41 M+6rK6xAyEjyWUSgL8i/ifnrRTRqYzQkaptANJvjrm3HuA2UPbagV0/jbHE8rlgcRMFc dhUR5kE+NqQpbus6FApqUX1tG8dkY756lX57bCucXah/6iRMdRlrKMRWGFBmnYY+oxxG eFLvSi9ybyA2qhFMRCNLCLdGgrS7pAjtZtrPCMPTl+Oyj3rxpf64ytJxwVmh7Klw8S7Q xVRg== 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=Cd3z0QXUyq7/upJ7h5viY9DcZqTKU4LsHRGqXjDjf+g=; b=q0Nvd5DqKaaeQA5WV1zTd/kB45tSaxLB/2r8IGw/XBfxuuAKIy0CNBg9C8nFjUt3vg 6XRbiN5U1NSD2y6KRNe3Cx/8XWtAfuRLrd7F8csSCVsriBUzn/YrZnx3aKHLvyzVgk10 w5gdd7OEw7fKFmrT+LM7tcwjz4F6wSxteCaPWRAEhCPNgSfj3nHR3RFmGBuCw4ol1Av/ bOWGrwP8yADj8Bh0dkaJDkDUgPhEtgCgp2nN0p4Ytx0mwOLJjR8qZ586GFDjPiOUEwn8 tEZh/chUbg3JQRV3UghFIxQxky7pl4buZC8Mo2j/ZlIbRx2tUVGERLiTOp5iCphn3+B6 lpPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WTXGLMIc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x39-20020a056a0018a700b004f707cc980esi9462616pfh.28.2022.03.11.15.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 15:08:55 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WTXGLMIc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 271853A058D; Fri, 11 Mar 2022 14:06:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346753AbiCKGoO (ORCPT + 99 others); Fri, 11 Mar 2022 01:44:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343852AbiCKGoM (ORCPT ); Fri, 11 Mar 2022 01:44:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90DFB157206; Thu, 10 Mar 2022 22:43:09 -0800 (PST) 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 2849861D27; Fri, 11 Mar 2022 06:43:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13069C340EC; Fri, 11 Mar 2022 06:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646980988; bh=Hynl40FMFdNLPC1cJ0x+jyJPX9TWT5Ynp4mHQb6/Kpw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WTXGLMIcVU+EXlGAqKMJPMXfDp1ZvDjCUBR73pLjFiNwTj7iFxEs6ynADKyKvJUVo u5ytKDB2NiYi9Wg+sNRwKAZ2lp7Vz5YhozEwdjaS1a0dymTIt11x5wc6vi1fC54pi6 rrzy3ty1+I8n0jue5jdWSwJ1bsyI3zh+fOvCyPUc= Date: Fri, 11 Mar 2022 07:43:04 +0100 From: Greg KH To: Wei Ming Chen Cc: linux-kernel@vger.kernel.org, andreyknvl@gmail.com, balbi@kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v2] usb: raw-gadget: return -EINVAL if no proper ep address available Message-ID: References: <20220311032238.3978-1-jj251510319013@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220311032238.3978-1-jj251510319013@gmail.com> X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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, Mar 11, 2022 at 11:22:38AM +0800, Wei Ming Chen wrote: > If we try to use raw_ioctl_ep_enable() for ep5in on a hardware that > only support from ep1-ep4 for both in and out direction, it will return > -EBUSY originally. > > I think it will be more intuitive if we return -EINVAL, because -EBUSY > sounds like ep5in is not available now, but might be available in the > future. > > Signed-off-by: Wei Ming Chen > --- > drivers/usb/gadget/legacy/raw_gadget.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/gadget/legacy/raw_gadget.c b/drivers/usb/gadget/legacy/raw_gadget.c > index d86c3a36441e..e5707626c4d4 100644 > --- a/drivers/usb/gadget/legacy/raw_gadget.c > +++ b/drivers/usb/gadget/legacy/raw_gadget.c > @@ -758,6 +758,7 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value) > unsigned long flags; > struct usb_endpoint_descriptor *desc; > struct raw_ep *ep; > + bool ep_props_matched = false; > > desc = memdup_user((void __user *)value, sizeof(*desc)); > if (IS_ERR(desc)) > @@ -787,13 +788,14 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value) > > for (i = 0; i < dev->eps_num; i++) { > ep = &dev->eps[i]; > - if (ep->state != STATE_EP_DISABLED) > - continue; > if (ep->addr != usb_endpoint_num(desc) && > ep->addr != USB_RAW_EP_ADDR_ANY) > continue; > if (!usb_gadget_ep_match_desc(dev->gadget, ep->ep, desc, NULL)) > continue; > + ep_props_matched = true; > + if (ep->state != STATE_EP_DISABLED) > + continue; > ep->ep->desc = desc; > ret = usb_ep_enable(ep->ep); > if (ret < 0) { > @@ -815,8 +817,13 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value) > goto out_unlock; > } > > - dev_dbg(&dev->gadget->dev, "fail, no gadget endpoints available\n"); > - ret = -EBUSY; > + if (!ep_props_matched) { > + dev_dbg(&dev->gadget->dev, "fail, bad endpoint descriptor\n"); > + ret = -EINVAL; > + } else { > + dev_dbg(&dev->gadget->dev, "fail, no endpoints available\n"); > + ret = -EBUSY; > + } > > out_free: > kfree(desc); > -- > 2.25.1 > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot