Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1764864pxp; Mon, 7 Mar 2022 01:46:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZaDpy6jo9tHubgTL2m8t7aLACwnib8fbkMz72ENus2YlcMnVIDOfu/rYF6uKPj50qVIST X-Received: by 2002:a17:907:76f7:b0:6d6:e922:3cd with SMTP id kg23-20020a17090776f700b006d6e92203cdmr8883637ejc.386.1646646365204; Mon, 07 Mar 2022 01:46:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646646365; cv=none; d=google.com; s=arc-20160816; b=LNljyMl9sF2EZk3oXgr0lZg2KObGyglpuxOsf3VCqIgldvNUSKCNn2t1pALCv4FK6N xvqf7ZpeMoaAaBko7vIIKfBeaZTJH7plaY/+5rTka/l6GHDi6Qz9XWyrbAvXnp/s//bZ xcNPLMU2tGXpb+gIIT9IzI/n8gnoCebcS1yHCNxsR4LUu8AMqBI35UO3CCOGJLmVnOd5 kCg2kBHUG2ctArGPgm47kRecu+2IsxQya60BZwvL57xCbXk4ANRzBwrig4OGLrJrXWXD BaLNSGI6GH0eNUNxOtK+3J7L872gUHeGMmHiWk6PIu2jdXO2ZoA8uJG3io3Q/DB1qMvG ptqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l//L7ocJGxqmRL5eS8666SYNKXhr7tX6wV7H1PEFO9E=; b=JKMQYbK0NJhbFCs822+t4+Ifmu14CobGqjdkmI3tZWCHl2egIC3CJQkEkwq4yWwIby BMhOEN61GMHlvat+0MzltVIAu77sdWx195nD8AwG75TzVyhXEjGbpbkZc4WwBp5wReuc zQdZdsXrzKUkZ4F/5aYEUy/z1FuWtXArOS+BKPN7JIDDAuneJpvApAuxshvNAlk4R696 MBuTU58lNrGtTp8Gky9CGlcx+W5vvbsE7JWFBKaWN2fSbtxs7GIBqgoNTJjRiL/8hkBK 5kUEeFsy/CdEem74ZPO7oqDdQnOSnfP6vv04qpWa3eoNNZ3rFdAG3CmNV4eSeKcMfFHt wC/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oM1vSktx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a056402050c00b00416475ba619si1666825edv.435.2022.03.07.01.45.42; Mon, 07 Mar 2022 01:46:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oM1vSktx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234049AbiCFRws (ORCPT + 99 others); Sun, 6 Mar 2022 12:52:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234053AbiCFRwa (ORCPT ); Sun, 6 Mar 2022 12:52:30 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EAD949903; Sun, 6 Mar 2022 09:51:29 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id kt27so27576799ejb.0; Sun, 06 Mar 2022 09:51:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l//L7ocJGxqmRL5eS8666SYNKXhr7tX6wV7H1PEFO9E=; b=oM1vSktxE2Qr655ln7crRO/JCD5alzuN5GehEboD4d3pPEfnfRXPXwtGqHtPmzqC+Q AHEVWbibeibbpKr7SoPQTJWdXWME7xXZ2Y0g9GkAiwkBGbYvw1Cwc1bFjkJL75A9IYA7 gbb6/0SrZEaIF4iq9l4NdHKO7eyWiZa07lbpT4rF+IVeLtcteDs8L/dJZsNJot6TfO3+ I/sGZxCUV3T754Zr+SB072WVlEKfInG1RuqyR0fa4GMz4Nn7SVQDbssvq3jhSHDUgnOU /71LXM5AX+u1FeIITq9zCZ5+gv6MK018+GgSA7If2s7d+o2vpePtQMnbHx2tR8ZWiwdP PgPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l//L7ocJGxqmRL5eS8666SYNKXhr7tX6wV7H1PEFO9E=; b=2e5BGMf4wiDB5SPMb0rhKSVObo6RMIFjjfO91Uw5f7DcqtfVRUqjP5qo65ileS7EJf WDUZfk2W1/UMaUcRkKOZU3G5bq/+L+9muQSBKNW9MEGXJni0evgBlK30hWhh9LgXTFoj ++y20bK/YD0pdcj2p+7sufa58FR1Rx5jzzk/Q8KncrFD3h8ddpoVOeo2hpcNh7ZrH4Rd PbvD00TU6f5x1E7nC9hZsF1DJgEmhN83Y8hFe5TVuKc3lvKqeSM3q1ibz+IG1fMmwhN+ dreFKOwljYTycJsAubzwmb1AtX8UHCB+0qLZHTIjpfwgm+OjStAdiujGjRfqy2v1TtVc ILUQ== X-Gm-Message-State: AOAM531llO/miJc64G1KVoF23+NJVAd10HDRzShmZIV8TcjH8S4KhBOF XLb5q1JHxWt8QOgDNckZdjo= X-Received: by 2002:a17:906:5597:b0:6ce:f3cc:14e8 with SMTP id y23-20020a170906559700b006cef3cc14e8mr6410110ejp.426.1646589087983; Sun, 06 Mar 2022 09:51:27 -0800 (PST) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id 20-20020a17090601d400b006caff964e30sm4052606ejj.19.2022.03.06.09.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Mar 2022 09:51:27 -0800 (PST) From: Jakob Koschel To: Greg Kroah-Hartman Cc: Jakob Koschel , linux-kernel@vger.kernel.org, Linus Torvalds , Felipe Balbi , Joel Stanley , Andrew Jeffery , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Cristian Birsan , Al Cooper , Li Yang , Vladimir Zapolskiy , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Michal Simek , linux-usb@vger.kernel.org (open list:USB GADGET/PERIPHERAL SUBSYSTEM), Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH 15/26] usb: gadget: udc-xilinx: remove usage of list iterator past the loop body Date: Sun, 6 Mar 2022 18:50:23 +0100 Message-Id: <20220306175034.3084609-16-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220306175034.3084609-1-jakobkoschel@gmail.com> References: <20220306175034.3084609-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the list representing the request queue does not contain the expected request, the value of the list_for_each_entry() iterator will not point to a valid structure. To avoid type confusion in such case, the list iterator scope will be limited to the list_for_each_entry() loop. In preparation to limiting scope of the list iterator to the list traversal loop, use a dedicated pointer to point to the found request object [1]. Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/ Signed-off-by: Jakob Koschel --- drivers/usb/gadget/udc/udc-xilinx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c index 2907fad04e2c..34b7000f0602 100644 --- a/drivers/usb/gadget/udc/udc-xilinx.c +++ b/drivers/usb/gadget/udc/udc-xilinx.c @@ -1136,17 +1136,20 @@ static int xudc_ep_queue(struct usb_ep *_ep, struct usb_request *_req, static int xudc_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) { struct xusb_ep *ep = to_xusb_ep(_ep); - struct xusb_req *req = to_xusb_req(_req); + struct xusb_req *req = NULL; + struct xusb_req *tmp; struct xusb_udc *udc = ep->udc; unsigned long flags; spin_lock_irqsave(&udc->lock, flags); /* Make sure it's actually queued on this endpoint */ - list_for_each_entry(req, &ep->queue, queue) { - if (&req->usb_req == _req) + list_for_each_entry(tmp, &ep->queue, queue) { + if (&tmp->usb_req == _req) { + req = tmp; break; + } } - if (&req->usb_req != _req) { + if (!req) { spin_unlock_irqrestore(&udc->lock, flags); return -EINVAL; } -- 2.25.1