Received: by 10.223.185.116 with SMTP id b49csp6013458wrg; Wed, 28 Feb 2018 02:28:19 -0800 (PST) X-Google-Smtp-Source: AG47ELtEsr4/yNK00NKXQlDsRnEg8aw2qQOykM/qFjMsYraRNP++UUK+GS/q7x3CnxkQxtmiCu1I X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr4869688plx.420.1519813699335; Wed, 28 Feb 2018 02:28:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519813699; cv=none; d=google.com; s=arc-20160816; b=jG4sVTJcSL7jf8ZCogGHD/5USSTSQLn0dI9W4DdX9N8Ar7wGUlICVpkVuFNwfFAVyV PNtKngeT2m52tEAhitODihks34oozmvuOUKMmv02wNVS/vi8r5/z5L1hvcetLIIH9m6O Eo+RQeZ6/AIgaDpsQBzH3XIOFdeDDaDPsxq8/dscA7GQMc/fAgY/GbD8u+OHl56/7Iwu MoxYetwoV936d/vqRBM//JhSOFUf6XnPOv30RAV+zS8iMq/PwXLt3bw4o0o5EEyJOexC VMgicDjh9+qyPWvHNn8KlQ6wikRBLh50EwtsKzBeE5l7hBV187BbcwTYCtkAy9TeAoyo IS4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=/U1RpFanjX9eeGMyDzlNMYiv5NehaVZ6K5atTqQd7e8=; b=wjzR1fbwtv9J2Jcj9m/ixriZcaztz8K703rvjxN4manX5yH4fUvX6dIbGtXeumYE99 /1UDHVrc2UxPOhnczb7VJjxJdatzpF2DVQr23Hg1pjYHS3sAz4FQRxNsWBPonMC2L9LL SapChMNoR4ZjT7rMm8f/7B+CdSfqA4Uxo6ccRyqTyUA9v/DSBaKeOxd8ze1bMXkKcEWh sMuvinoibXRlfoTNnKLqox23WpewV41D/Ja4MLEpw3s6cMjU7ydsWNDBu7CA/a4Xp0Xr Vgk1lfz4n6/Bc1KpUuK6+WyuboMRC3/J46JBpsSKOWTzGzLcvzRc5xgRV7XSLC8OrxdJ 7gxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70-v6si1085425pla.64.2018.02.28.02.28.02; Wed, 28 Feb 2018 02:28:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752317AbeB1K1U convert rfc822-to-8bit (ORCPT + 99 others); Wed, 28 Feb 2018 05:27:20 -0500 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:36290 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752085AbeB1K1S (ORCPT ); Wed, 28 Feb 2018 05:27:18 -0500 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0BB0410C1243; Wed, 28 Feb 2018 02:27:18 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id DCE253CA4; Wed, 28 Feb 2018 02:27:17 -0800 (PST) Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2-vip.internal.synopsys.com [10.12.239.238]) by mailhost.synopsys.com (Postfix) with ESMTP id CE08C3CA1; Wed, 28 Feb 2018 02:27:17 -0800 (PST) Received: from AM04WEHTCA.internal.synopsys.com (10.116.16.190) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.266.1; Wed, 28 Feb 2018 02:27:17 -0800 Received: from AM04WEMBXB.internal.synopsys.com ([fe80::1006:bcdd:1b7:579b]) by am04wehtca.internal.synopsys.com ([::1]) with mapi id 14.03.0361.001; Wed, 28 Feb 2018 14:27:14 +0400 From: Minas Harutyunyan To: "Zengtao (B)" , "johnyoun@synopsys.com" CC: "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: Possible usb_request leak in the function dwc2_gadget_complete_isoc_request_ddma Thread-Topic: Possible usb_request leak in the function dwc2_gadget_complete_isoc_request_ddma Thread-Index: AQHTsH6zU1BbgxUqlUykEmiFUhyGow== Date: Wed, 28 Feb 2018 10:27:14 +0000 Message-ID: <410670D7E743164D87FA6160E7907A560113A9C13B@am04wembxb.internal.synopsys.com> References: <678F3D1BB717D949B966B68EAEB446ED0C861F47@DGGEMM506-MBX.china.huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.116.70.62] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2/28/2018 1:00 PM, Zengtao (B) wrote: > Hi johnyoun: > > I found a suspected bug, and I am writing to confirm with you. > > In the function dwc2_gadget_complete_isoc_request_ddma(drivers/usb/dwc2/gadget.c). > Only the first request from the eq queue is processed while maybe there are more than one descriptors done by the HW. > > 1. Each usb request is associated with a DMA descriptor, but this is not reflect in the driver, so when one DMA descriptor is done, > we don't know which usb request is done, but I think if only one DMA descriptor is done, we can know that the first USB request in > eq queue is done, because the HW DMA descriptor and SW usb request are both in sequence. > > 2. In the function dwc2_gadget_complete_isoc_request_ddma, we may complete more than one DMA descriptor but only the first > Usb request is processed, but in fact, we should all the usb requests associated with all the done DMA descriptors. > > 3. I noticed that each DMA descriptor is configured to report an interrupt, and if each DMA descriptor generate an interrupt, the above > Flow should be ok, but the interrupts can merge and we have used the depdma to figure out the largest finished DMA descriptor index. > Why you suspect that subsequent interrupts can be merged? Did you see this case? Can you provide a log? Even in case of minimal interval=1, time between 2 subsequent interrupts should be about 125us. It's fully enough to process target descriptor, complete request, enqueue new request and prepare new descriptor. Thanks, Minas > Looking forward your reply. > > Thank you. > > Regards > Zengtao > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DwIDAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=6z9Al9FrHR_ZqbbtSAsD16pvOL2S3XHxQnSzq8kusyI&m=vbKt9jwY5FRUysFlZg1CB6HKRyFACygkwZBO0mvSQDc&s=7rLKr3g3UyOZT22GAer-w5wDtv-Bb5awlncAJQ1OICM&e= >