Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp6045708rdb; Mon, 18 Sep 2023 02:17:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwz46NdhtETYkRklf4qvj1h2WxjJpf/PtGKrlGHODPgZ3YdQmPEZ8vjlV74GYGGzYigQfd X-Received: by 2002:a05:6a20:a127:b0:159:1bd8:fc7a with SMTP id q39-20020a056a20a12700b001591bd8fc7amr7977382pzk.40.1695028630312; Mon, 18 Sep 2023 02:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695028630; cv=none; d=google.com; s=arc-20160816; b=L0hBSP8cQXiFknEgJEBOaevedi8IDd6ldxYHhRn0oeA4bO1KY8upTFk9O5C9GpO24H fcm5VBIKTDEOZSyRCLqMbEtGBKJz5OCuXzQm9UmowDPROE674Nc2HL9U44PaHZtWTTvA wmAkFt35GQjipccMKeHT+6TAI9OnkOBoBDnVz5gdo3RU66rb8+5DCd30ZSQTPMa9KA5P h+NDRTfb3gdkRpzN98ZAI3sQcEw2KgpRYJv+EKosJpIqCJuv4/Kjqf27aROd+2LNnCZw FCWtUr1PLcVu7HaSM/iZh7rjuGSlhjX3z0LEiaBodMqfuvzdI96F5HIG+kl3UhT+ETDh QJtQ== 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=aVSEeYpjNMNoqFQZ/R8PoGZxkhdzIm/ov1R1fMGHab0=; fh=yd3XZ2RlNnlhjAkoiwAUGZNEhBSv7cT3/4Q2nQU3JPE=; b=miPFzlov3fMNd9MTNS5SmCWVjJoJ0DCqsJ7lEifpx8fsG2f3EHxzHYz7cKbMOFWUWP /Qn8A2JsKnXuMGWyfB54o8XtFr1t0g2YK4E18fJmKZ4yvOyNrHJEaMKt4koTSXQup/NH 68Anl8SFgUg2OxP4qM5tOa0l2iVJ0Uw0nVBtC4sEE/cimoWpX55SdUVqZAY0Ql/qPZVB IymdvYAy8JJcoCC1KtvEA9f0cIM+Ve54y0p97vWpwjSj/+GVqeCKE+hEIn/yjFOwRpXz 7Pfw6YmN3UIGldGCxsAedmmP7Ix3XJobgWEhhmMb5kIY7Xs0AlxsBFg/iqrB8BJlhgs8 US2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p5Ywz1ZV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00578889362a7si1456172pgb.5.2023.09.18.02.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 02:17:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p5Ywz1ZV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B66FC806AFE9; Mon, 18 Sep 2023 00:04:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239978AbjIRHEK (ORCPT + 99 others); Mon, 18 Sep 2023 03:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240079AbjIRHEE (ORCPT ); Mon, 18 Sep 2023 03:04:04 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF1D9121 for ; Mon, 18 Sep 2023 00:03:44 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16DF4C433C7; Mon, 18 Sep 2023 07:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695020624; bh=opjulFiGRuWJn3Kbr+JNW9QH6jk0wc+wSlz5wGS+cYs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p5Ywz1ZVlBdMvCo2Xj/XXT0VztyffGjTs4GlZ/6PVUk3jCNSZTu/Z8ZLYXNq7PmMA Pzec9PzHCI/f0czfR43ykFT0m8aTYGTjUITwx5N7Mc04RDkaIaXpe2WigxUQIeF6XM BsDgoJWZA64LiCtb6GXp65VCn+AMpbJmQTOjkfTk= Date: Mon, 18 Sep 2023 09:03:39 +0200 From: Greg KH To: Xingxing Luo Cc: b-liu@ti.com, s.shtylyov@omp.ru, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, xingxing0070.luo@gmail.com, Zhiyong.Liu@unisoc.com, Cixi.Geng1@unisoc.com, Orson.Zhai@unisoc.com, zhang.lyra@gmail.com Subject: Re: [PATCH V2] usb: musb: Get the musb_qh poniter after musb_giveback Message-ID: <2023091824-balancing-drizzly-4921@gregkh> References: <20230918061038.30949-1-xingxing.luo@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230918061038.30949-1-xingxing.luo@unisoc.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 18 Sep 2023 00:04:44 -0700 (PDT) On Mon, Sep 18, 2023 at 02:10:38PM +0800, Xingxing Luo wrote: > When multiple threads are performing USB transmission, musb->lock will be > unlocked when musb_giveback is executed. At this time, qh may be released > in the dequeue process in other threads, resulting in a wild pointer, so > it needs to be here get qh again, and judge whether qh is NULL, and when > dequeue, you need to set qh to NULL. > > Fixes: dbac5d07d13e ("usb: musb: host: don't start next rx urb if current one failed") > Signed-off-by: Xingxing Luo > --- > drivers/usb/musb/musb_host.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c > index a02c29216955..bc4507781167 100644 > --- a/drivers/usb/musb/musb_host.c > +++ b/drivers/usb/musb/musb_host.c > @@ -321,10 +321,16 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, > musb_giveback(musb, urb, status); > qh->is_ready = ready; > > + /* > + * musb->lock had been unlocked in musb_giveback, so qh may > + * be freed, need to get it again > + */ > + qh = musb_ep_get_qh(hw_ep, is_in); > + > /* reclaim resources (and bandwidth) ASAP; deschedule it, and > * invalidate qh as soon as list_empty(&hep->urb_list) > */ > - if (list_empty(&qh->hep->urb_list)) { > + if (qh && list_empty(&qh->hep->urb_list)) { > struct list_head *head; > struct dma_controller *dma = musb->dma_controller; > > @@ -2398,6 +2404,7 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) > * and its URB list has emptied, recycle this qh. > */ > if (ready && list_empty(&qh->hep->urb_list)) { > + musb_ep_set_qh(qh->hw_ep, is_in, NULL); > qh->hep->hcpriv = NULL; > list_del(&qh->ring); > kfree(qh); > -- > 2.17.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/process/submitting-patches.rst for what needs to be done here to properly describe this. - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documetnation/process/stable-kernel-rules.rst file for how to resolve 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