Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3807295rdb; Thu, 14 Sep 2023 03:21:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoBdOGTlnkYgNy47f6keGxhP8LcF75AeloKew1GNqZLmQgpMnq0blFDJ4J4M4n9pkVQ735 X-Received: by 2002:a17:90b:695:b0:267:eefe:d0b5 with SMTP id m21-20020a17090b069500b00267eefed0b5mr4577346pjz.46.1694686879163; Thu, 14 Sep 2023 03:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694686879; cv=none; d=google.com; s=arc-20160816; b=rvpaQaZ63njWuCosf9Kn90Yzpv3L9/uYqThnKrRLJdxfopDaWRcJo4yomhlJD34MmK Uu51q5fLIoawoSxRtBXIV5CenjP2LR39N53TIucEIES4f2NtbsV6B58SzRi5lh1KSJII UnO8sjYsZb5rPx1oePy9s/j+06ERGVSxY1zjOX/75vPP9AIRWge258T371p2AzVIVo5l JFnqvE2Q014k8BOL1Kj+PuwAACzxlkbPX3gtjGX+oOhQ2IfHR1Uo9Mfor2+grfuTo/p3 8lO1xMiL/RwNxZs0r4u/QxmvVa2CmaUMGlb0lEq+xMuxpAsbZcvSClvA8JtzFL0TPzaU 9wqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject; bh=3OvL9bS0ILvB195BoTi1rENcUJmquGJKaVV0VC5EiRE=; fh=AIZKpeTVXjB76zNQr5wCdL/OAoxfklzbA1TXhVNXCNU=; b=xuXFZEUKmGivg74GZ9wtRgXmnz37XfYS79WYz2hC3Hz/srQtwV03ooKrnnXVNQTbCv FVJxQcYTfmfyG81i9ivm4xfWm0wArps0Zi2fF7eCjbtg/ud3rZ+AjZUAb/SmcBDoLeMt AnC6dqn83Y5+jmV0BbsQ4E3Xf4xMQjoCFqeHSAz6dJ+sf1cLlKiNcef6EV96OXI3T6r1 WFt/9jzjl+Nql8AfdYuS9v9xgztbzoZwAZ7xL9pLU0ZX2mQjiEAHxgHB7qGpwKUBvLC3 ON4dX78blOE0uFchQKdsiujTtrR0SbhodYZLEpaVBt8f1QX5aM0DXeaKlwdd6xZGo1mg 4o5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u6-20020a17090a1f0600b0027405eddd3fsi3492579pja.19.2023.09.14.03.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 03:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5B43A81049A0; Thu, 14 Sep 2023 03:06:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237947AbjINKG3 (ORCPT + 99 others); Thu, 14 Sep 2023 06:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbjINKGZ (ORCPT ); Thu, 14 Sep 2023 06:06:25 -0400 Received: from mx01.omp.ru (mx01.omp.ru [90.154.21.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 799F41BE3; Thu, 14 Sep 2023 03:06:20 -0700 (PDT) Received: from [192.168.1.103] (178.176.78.252) by msexch01.omp.ru (10.188.4.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.14; Thu, 14 Sep 2023 13:06:15 +0300 Subject: Re: [PATCH] usb: musb: Get the musb_qh poniter after musb_giveback To: Xingxing Luo , , CC: , , , , , , References: <20230914015656.20856-1-xingxing.luo@unisoc.com> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <8365ba2a-8ecd-d055-e962-3a7f2bfdbfb0@omp.ru> Date: Thu, 14 Sep 2023 13:06:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20230914015656.20856-1-xingxing.luo@unisoc.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [178.176.78.252] X-ClientProxiedBy: msexch01.omp.ru (10.188.4.12) To msexch01.omp.ru (10.188.4.12) X-KSE-ServerInfo: msexch01.omp.ru, 9 X-KSE-AntiSpam-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 5.9.59, Database issued on: 09/14/2023 09:39:25 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 59 X-KSE-AntiSpam-Info: Lua profiles 179856 [Sep 14 2023] X-KSE-AntiSpam-Info: Version: 5.9.59.0 X-KSE-AntiSpam-Info: Envelope from: s.shtylyov@omp.ru X-KSE-AntiSpam-Info: LuaCore: 530 530 ecb1547b3f72d1df4c71c0b60e67ba6b4aea5432 X-KSE-AntiSpam-Info: {rep_avail} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: {relay has no DNS name} X-KSE-AntiSpam-Info: {SMTP from is not routable} X-KSE-AntiSpam-Info: {Found in DNSBL: 178.176.78.252 in (user) b.barracudacentral.org} X-KSE-AntiSpam-Info: {Found in DNSBL: 178.176.78.252 in (user) dbl.spamhaus.org} X-KSE-AntiSpam-Info: 127.0.0.199:7.1.2;omp.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1 X-KSE-AntiSpam-Info: FromAlignment: s X-KSE-AntiSpam-Info: {rdns complete} X-KSE-AntiSpam-Info: {fromrtbl complete} X-KSE-AntiSpam-Info: ApMailHostAddress: 178.176.78.252 X-KSE-AntiSpam-Info: Rate: 59 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dmarc=none header.from=omp.ru;spf=none smtp.mailfrom=omp.ru;dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 09/14/2023 09:47:00 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 9/14/2023 9:01:00 AM X-KSE-Attachment-Filter-Triggered-Rules: Clean X-KSE-Attachment-Filter-Triggered-Filters: Clean X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit 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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 03:06:38 -0700 (PDT) X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 agentk.vger.email Hello! On 9/14/23 4:56 AM, 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..9df27db5847a 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 somtimes qh Sometimes? > + * may freed, need 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 != NULL && list_empty(&qh->hep->urb_list)) { Just qh, perhaps? [...] MBR, Sergey