From patchwork Tue Jul 7 15:25:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 50833 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E5004229FC for ; Tue, 7 Jul 2015 15:25:29 +0000 (UTC) Received: by wgfk9 with SMTP id k9sf62347827wgf.1 for ; Tue, 07 Jul 2015 08:25:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=/NymFkYo2iJj3Z8qbb+KvjsetwXbFjWpSPRiOHMJRPQ=; b=NXdmTFNIhXfviZiP+QmoHmo/QRFSUwyyZ35jZsY8T5WvJ2IZTukHiPCj1pDZryY4DQ xFLYaQfbYbckUUGFINJKl7XB+Qw15qzVv0gbdLoM5rNA8QfGpHMRa5WNBmOuCbv+P+Yi m73kEWRv1T112u3NFxm8SOsfeli7efP3aATYo29Y6gRNbiWRjwCk9azWADLiLpqY8syb 6kHCH1DkKkTQq7kuNIBJTOCPlr4Nzog5D7D6zVtOiMJYZlfhJ6dbg8yToRrA9H2zw009 /TlA6CGrsM/mAsX+prw8M/bDunNvH8u0wpYA/CZ/zZdT8pACe7daZ/1O4Ro3joDBX8Tk 1o0g== X-Gm-Message-State: ALoCoQliTVGmxkTGvb1kEvqEvNFz4TNiBvs99Uzemvs/rCC0k0uGEXZ7mLhCjbpPol7sCl3swfTA X-Received: by 10.112.255.66 with SMTP id ao2mr2332053lbd.15.1436282729211; Tue, 07 Jul 2015 08:25:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.136 with SMTP id dc8ls198811lad.101.gmail; Tue, 07 Jul 2015 08:25:29 -0700 (PDT) X-Received: by 10.112.147.233 with SMTP id tn9mr4478687lbb.119.1436282729059; Tue, 07 Jul 2015 08:25:29 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id y9si18372483lbo.119.2015.07.07.08.25.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2015 08:25:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by laar3 with SMTP id r3so200667632laa.0 for ; Tue, 07 Jul 2015 08:25:29 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr4539228lbc.19.1436282728971; Tue, 07 Jul 2015 08:25:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2464739lbb; Tue, 7 Jul 2015 08:25:27 -0700 (PDT) X-Received: by 10.68.89.164 with SMTP id bp4mr9880273pbb.41.1436282726409; Tue, 07 Jul 2015 08:25:26 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si35193366pdg.219.2015.07.07.08.25.25; Tue, 07 Jul 2015 08:25:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932300AbbGGPZX (ORCPT + 4 others); Tue, 7 Jul 2015 11:25:23 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:36401 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932065AbbGGPZJ (ORCPT ); Tue, 7 Jul 2015 11:25:09 -0400 Received: by wgbgr6 with SMTP id gr6so17303081wgb.3 for ; Tue, 07 Jul 2015 08:25:07 -0700 (PDT) X-Received: by 10.194.112.3 with SMTP id im3mr9758066wjb.54.1436282707475; Tue, 07 Jul 2015 08:25:07 -0700 (PDT) Received: from arch-late.dtvresearch.loc (a95-92-118-66.cpe.netcabo.pt. [95.92.118.66]) by mx.google.com with ESMTPSA id k16sm33881116wjr.7.2015.07.07.08.25.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jul 2015 08:25:06 -0700 (PDT) From: Rui Miguel Silva To: Felipe Balbi Cc: linux-usb@vger.kernel.org, Rui Miguel Silva Subject: [PATCH] usb: gadget: dummy_hcd: check hcd at urb enqueue Date: Tue, 7 Jul 2015 16:25:00 +0100 Message-Id: <1436282700-11028-1-git-send-email-rui.silva@linaro.org> X-Mailer: git-send-email 2.4.5 Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rui.silva@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When processing urb list in dummy_timer and an ep goes away, the urb is giveback with an -EPROTO error. However the same urb can be enqueued once again and the loop in dummy_timer never get out. To fix that, make sure the dummy_hcd is enabled at enqueue time to avoid adding urb to the urbp list. Signed-off-by: Rui Miguel Silva --- drivers/usb/gadget/udc/dummy_hcd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index f5400b8..30f1563 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -926,8 +926,6 @@ static int dummy_udc_stop(struct usb_gadget *g) return 0; } -#undef is_enabled - /* The gadget structure is stored inside the hcd structure and will be * released along with it. */ static void init_dummy_udc_hw(struct dummy *dum) @@ -1157,6 +1155,10 @@ static int dummy_urb_enqueue( urbp->miter_started = 0; dum_hcd = hcd_to_dummy_hcd(hcd); + if (!is_enabled(dum_hcd)) { + kfree(urbp); + return -ESHUTDOWN; + } spin_lock_irqsave(&dum_hcd->dum->lock, flags); rc = dummy_validate_stream(dum_hcd, urb); @@ -1191,6 +1193,8 @@ static int dummy_urb_enqueue( return rc; } +#undef is_enabled + static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { struct dummy_hcd *dum_hcd;