Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1078918pxb; Tue, 9 Nov 2021 04:55:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6nqyO3o5u/m3SFNczIdY7hM4uAiIj/jopXz7ThgV5i2JhAYAEAQeOsDsBuNv6gll9ScmM X-Received: by 2002:a17:906:57c2:: with SMTP id u2mr9713976ejr.8.1636462503662; Tue, 09 Nov 2021 04:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636462503; cv=none; d=google.com; s=arc-20160816; b=fZ5qmq4PhaQTctFUkBOHAc3bDeF/inLLBOiwK+j5WGn49Hz60LO6EUEEXLDNhlxXl7 MSta7qm9xlkuR6E+UlUirlWBdIW9RHdyD9GQ1QBzh6FVRwOIPnTJbx28HY7bbGdQGYhe lHEOIx8yQDXs3K+QWU+0mw+lbmjhk6m6Un4Vw4oEYgqM/gPiA8Piit2UjfXNqNlOUQov JoWM3MQOwVYMQJSWA3s0LXis7EmXTXl8Ebeotn1VUD47HHnJDH466NtW5+ebolR0jEj7 T+pwiEPeI5g2ZzVWfb7DyScos0ZFFfZWa2Ptv/htp4jxfo2aXYqYg1hKvdMUhi2VnhAw Y4VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=wChQfCcRN8/h4bsmukuc7LMGPInLM49zrDhyAhinlqc=; b=QbEEZ3AOEReZkuog+g+XtL+oXgGWfqdtdjlLVVjiD90AwDdIxXT5NdqVT+ZqF8TO1k mstC4yrCkqwWp5YOznXm6eVUtwKhBuondHdX6thgoJc9YXuoMIbBvIR65QOUDn+t1cFt tYjc8y6hxrNvwEDxpfI4sMVJ7W4Zb3iix27yiBpwe0sNM7WiqlDaC0KHgw5uTFJ598HO /ZhXwSrcNHJvcn9Yp/Yu5irulyxir69uiinrdbH58FLNrrSY+KWGabihki0PUxMefSyD mCbJWfE3WfgJNg/yfFLMyaCWCp7ljhxCJSNgx6vD/eAzGZpaFjRs6ZHdPt+p1txGT3vq surg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=e1iCXh6F; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs37si31817797ejc.418.2021.11.09.04.54.38; Tue, 09 Nov 2021 04:55:03 -0800 (PST) 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=@google.com header.s=20210112 header.b=e1iCXh6F; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbhKIFNO (ORCPT + 99 others); Tue, 9 Nov 2021 00:13:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231839AbhKIFNM (ORCPT ); Tue, 9 Nov 2021 00:13:12 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62468C061766 for ; Mon, 8 Nov 2021 21:10:27 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id d5so30808512wrc.1 for ; Mon, 08 Nov 2021 21:10:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wChQfCcRN8/h4bsmukuc7LMGPInLM49zrDhyAhinlqc=; b=e1iCXh6FUM+zNl6Shpg9UNX5ZOG1m5JqUzsx7ykiMPNSCkQhzYki77QU18eiKEZXSH XlWbUC1hQxwoeKsPtDsnE1Wj26HzRehUzx04QB6IA4+M7k5ki5LSAFI+cCqivJjO56nS OXJc7Om1NK7Outorntm5sr1QGH2Hz9yw3eNMI4zoXp5nEGRH7m2+rHyF+KVNmR0gXK/c 5pBWpiMSHN16gqu/V7gIU6dEQ1Ikg+HTSIg0j2dTd/HSVcUlC4JJtd5/p5CaZGstXcdA TRsUh8zkfHf2jxZlh+g87wWqFUdmFn+VgkxAiJjTpKGtDrZu4NzTnWs5aIyDTYCoG8Ha IbuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wChQfCcRN8/h4bsmukuc7LMGPInLM49zrDhyAhinlqc=; b=XQpPa39L8tdf4sYcyuEyF9Zo64GsNsmpkWLDq9GGBmlAWMNf5B+U1Mj7nX++fF78vx kZ1E0+6ZrAPnfsE0pZV772y1LPRB2ovQyQKef1hbBWYcFkShAeyLd9WCLEo+SyUnfOy1 SQ8G6Xa9xvONZ4pMqJtWoavm1iu1bNErFsluXibkMB/zlA7m+nQtbcnOhyTzY5/TyB8p s7KH7ymEdPv/CbIKwdU4NShXPG4bkR0ji+pKpyZfmzZ+faxCwwrhaKtgd6PJeyVxqlJj GpYXmCrse53YWz6zZS1Ae72RZUgWlY5lXvzbW6SnyWrVpclREWC+fXzKVpOIU6tJpl1Z ppNw== X-Gm-Message-State: AOAM53326xM0eD4IeeqJxDN3E060u2sgIe39nm6OUGHoRCkQ4FNf3y4K Qb13jwoX7w85nXa0YfzgkqHxSu/ncfwvoJlhTpN5ow== X-Received: by 2002:a5d:5186:: with SMTP id k6mr6021712wrv.146.1636434625375; Mon, 08 Nov 2021 21:10:25 -0800 (PST) MIME-Version: 1.0 References: <20211104062616.948353-1-albertccwang@google.com> <20211106012513.GA19852@jackp-linux.qualcomm.com> In-Reply-To: <20211106012513.GA19852@jackp-linux.qualcomm.com> From: Albert Wang Date: Tue, 9 Nov 2021 13:10:13 +0800 Message-ID: Subject: Re: [PATCH] usb: dwc3: gadget: Fix null pointer exception To: Jack Pham Cc: balbi@kernel.org, gregkh@linuxfoundation.org, badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Wesley Cheng Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ok, let me do that. Thanks, Albert On Sat, Nov 6, 2021 at 9:25 AM Jack Pham wrote: > > On Thu, Nov 04, 2021 at 02:26:16PM +0800, Albert Wang wrote: > > In the endpoint interrupt functions > > dwc3_gadget_endpoint_transfer_in_progress() and > > dwc3_gadget_endpoint_trbs_complete() will dereference the endpoint > > descriptor. But it could be cleared in __dwc3_gadget_ep_disable() > > when accessory disconnected. So we need to check whether it is null > > or not before dereferencing it. > > > > Signed-off-by: Albert Wang > > Nice catch. I think this might have been caused when the call to > dwc3_remove_requests() in __dwc3_gadget_ep_disable() was moved after > the endpoint descriptors is cleared. So you can probably add: > > Fixes: f09ddcfcb8c5 ("usb: dwc3: gadget: Prevent EP queuing while > stopping transfers"). > > Reviewed-by: Jack Pham > > > --- > > drivers/usb/dwc3/gadget.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > > index 23de2a5a40d6..83c7344888fd 100644 > > --- a/drivers/usb/dwc3/gadget.c > > +++ b/drivers/usb/dwc3/gadget.c > > @@ -3252,6 +3252,9 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep, > > struct dwc3 *dwc = dep->dwc; > > bool no_started_trb = true; > > > > + if (!dep->endpoint.desc) > > + return no_started_trb; > > + > > dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); > > > > if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) > > @@ -3299,6 +3302,9 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, > > { > > int status = 0; > > > > + if (!dep->endpoint.desc) > > + return; > > + > > if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) > > dwc3_gadget_endpoint_frame_from_event(dep, event); > > > > -- > > 2.33.1.1089.g2158813163f-goog > >