From patchwork Fri Oct 17 17:16:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 38977 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C1EC1202DB for ; Fri, 17 Oct 2014 17:19:48 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id hi2sf800925wib.5 for ; Fri, 17 Oct 2014 10:19:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=hmzDmTzCR+b8l24CMX9huyWErOpHexZAuG+Phdo0u+s=; b=N+CQx/j3ySlRx9kOfoWar7XROGuSucomk8Gu2hduGKM/7e6CueUJXg45b6moXVzZPS dJA3+2gg0QIO+VnSJit5LhjsrAIF4B9HcgpFlPsEyOyF+icM9UNPhameuQVT4+FpsxBH 4Sja/cEHweqgOGt3Sxe4TKC+Qo+IK16sE6DRhwfz0zAHzOyQ5F4EL+/xPMRwsHIXW778 Y0TVhPe1U4cA9qw4xtVALyarF2YIo3lg7K8TbF1EykI+eW0OzM8J8awh16awLzOvG/VN GmLcrrF8SKt6wTR6xNRZ1xQog79Fl6R8tnuEYt0z3PMSbjnqstsTonkWq7TLA3hKjtKa JWlQ== X-Gm-Message-State: ALoCoQnMw5eH0wBb0GLTYcFdd2H5inP+v96EB3ps26zXqKxikAKnU5He881uE341XW1uvqZzDjjy X-Received: by 10.152.28.4 with SMTP id x4mr40158lag.7.1413566388000; Fri, 17 Oct 2014 10:19:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.230 with SMTP id m6ls303960laa.89.gmail; Fri, 17 Oct 2014 10:19:47 -0700 (PDT) X-Received: by 10.152.44.233 with SMTP id h9mr10114235lam.73.1413566387892; Fri, 17 Oct 2014 10:19:47 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id f1si3053256lam.8.2014.10.17.10.19.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 10:19:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ge10so1062058lab.24 for ; Fri, 17 Oct 2014 10:19:47 -0700 (PDT) X-Received: by 10.112.130.41 with SMTP id ob9mr10084749lbb.74.1413566387817; Fri, 17 Oct 2014 10:19:47 -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.84.229 with SMTP id c5csp268374lbz; Fri, 17 Oct 2014 10:19:47 -0700 (PDT) X-Received: by 10.68.69.68 with SMTP id c4mr2975799pbu.168.1413566386364; Fri, 17 Oct 2014 10:19:46 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id je3si1677144pbd.84.2014.10.17.10.19.45 for ; Fri, 17 Oct 2014 10:19:46 -0700 (PDT) Received-SPF: none (google.com: linux-usb-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753530AbaJQRSA (ORCPT + 3 others); Fri, 17 Oct 2014 13:18:00 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:44345 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753356AbaJQRR7 (ORCPT ); Fri, 17 Oct 2014 13:17:59 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9HHHot2008045; Fri, 17 Oct 2014 12:17:50 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9HHHoAR000781; Fri, 17 Oct 2014 12:17:50 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Fri, 17 Oct 2014 12:17:50 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9HHHnaU030164; Fri, 17 Oct 2014 12:17:50 -0500 From: Felipe Balbi To: Linux USB Mailing List CC: Greg KH , , Paul Zimmerman , , , , , , , Felipe Balbi Subject: [PATCH 23/67] usb: dwc3: gadget: WARN() on bogus usb_ep_queue() Date: Fri, 17 Oct 2014 12:16:30 -0500 Message-ID: <1413566234-13537-24-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.1.0.GIT In-Reply-To: <1413566234-13537-1-git-send-email-balbi@ti.com> References: <1413566234-13537-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 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: balbi@ti.com 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.51 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: , Some gadget/function drivers might want to do improper request recycling by allocating a single request from one particular endpoint and queueing it to another completely unrelated endpoint. One such case was found with f_loopback.c. To prevent such cases from happening again, let's WARN() so we get a loud enough failure and persuade users to report errors. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index d08666d..1f2a719 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1145,6 +1145,10 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request, return -ESHUTDOWN; } + if (WARN(req->dep != dep, "request %p belongs to '%s'\n", + request, req->dep->name)) + return -EINVAL; + dev_vdbg(dwc->dev, "queing request %p to %s length %d\n", request, ep->name, request->length); trace_dwc3_ep_queue(req);