Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3817632rdb; Thu, 14 Sep 2023 03:46:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGngT9LuwF4WgigZeD5ozW3FDIBPZXec+Sgf6Os4OSk5ei6udM+dYe9nOw8Jm5a3AtFXfIo X-Received: by 2002:a05:6a20:244f:b0:12f:c0c1:d70 with SMTP id t15-20020a056a20244f00b0012fc0c10d70mr5457611pzc.40.1694688383140; Thu, 14 Sep 2023 03:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694688383; cv=none; d=google.com; s=arc-20160816; b=fUh6Sdxb50ySwpVZOOo4J8fGfx5CpIl1+A7wMCb90RnxWAYfqHPOcpdMjm78FIMl2+ 8dHFRDzNHcYDyIxNzhv3oZhGPg8pYc7dpK3y+dU/ItmNNuXMXGg5ugfTEYx+c/jMEfhE IfewLgLAJn8UjdvdvDz4EXW/z6wMrPbaYRO2JZspY+0F73bHa4w/uXUNwKsa2zVvEvKC y4EBfuEwaYD8YotgAObet4zBe7oFFWhKLQW7gO6DP494Iw5QtEXTQ1JJSOtQpx9UBpKW 3t9x3kT5uh2Sc4FYvILnKvT19PWpYw1oLasmHx04SV3+xpGq3sfkwXKmWSncwE9gfPET 0ioA== 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 :references:cc:to:from:subject; bh=xZ35DW8sgm96dxdYPQE3a9kVolow3W5w7Mvh9Oz5+88=; fh=AIZKpeTVXjB76zNQr5wCdL/OAoxfklzbA1TXhVNXCNU=; b=BN4XIa9AO4pttltJyzx/CrHQF12XpBdNx9zlSY/cZvaAz7neSGlMQCDDoPcLR9+t2U 2H3le9FHvXsy779hqr85VzZs7zPCMgRHVz5V8DNuIg1sm/wZvsqtvn1TfxWAiKYRUyE8 AwrEnVvwsB4LHmNo752lxOEXmgvUFl9RlaiHIp0WhcAGQAI3qRO38Jn3+fwosBR0c2YA yYQLjZyMIBdREUzC+wH4dXz8RUaygxjq1GOciawD3mO5egJQhCC6EkQ/RJZk9CdimB+O M5GiSGcFgRzlAkBk5FZlRHZnWF1s/UlisJS0pcnuZvoxyfdRr1gAa4o+Yu1CmbWroes7 gsUw== 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:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id t9-20020a63d249000000b00565ecee8793si1300237pgi.875.2023.09.14.03.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 03:46:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 061D18295BE4; Thu, 14 Sep 2023 03:15:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237276AbjINKPj (ORCPT + 99 others); Thu, 14 Sep 2023 06:15:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbjINKPh (ORCPT ); Thu, 14 Sep 2023 06:15:37 -0400 Received: from mx01.omp.ru (mx01.omp.ru [90.154.21.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8011BE3; Thu, 14 Sep 2023 03:15:33 -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:15:30 +0300 Subject: Re: [PATCH] usb: musb: Get the musb_qh poniter after musb_giveback From: Sergey Shtylyov To: Xingxing Luo , , CC: , , , , , , References: <20230914015656.20856-1-xingxing.luo@unisoc.com> <8365ba2a-8ecd-d055-e962-3a7f2bfdbfb0@omp.ru> Organization: Open Mobile Platform Message-ID: <22c3a910-0c16-fe94-06e6-28650cf0e634@omp.ru> Date: Thu, 14 Sep 2023 13:15:30 +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: <8365ba2a-8ecd-d055-e962-3a7f2bfdbfb0@omp.ru> 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 10:01:12 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: d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;omp.ru: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 10:07: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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 03:15:41 -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 lipwig.vger.email On 9/14/23 1:06 PM, Sergey Shtylyov 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 + * may be freed, need to get it again Overlooked it in the 1st review, sorry... [...] MBR, Sergey