Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3500281pxp; Tue, 8 Mar 2022 16:03:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1nZCz2GLRp15NS6Vi815Zl9Frg5oYHKCcr9u+KIiVeKH8PCQWpbwRTZj7VFlFtEeVLMVU X-Received: by 2002:a63:4a44:0:b0:372:db13:5583 with SMTP id j4-20020a634a44000000b00372db135583mr16164192pgl.210.1646784190931; Tue, 08 Mar 2022 16:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646784190; cv=none; d=google.com; s=arc-20160816; b=BQ1rJkLkj4xYws/Rl1LSc8dfRA/tTLrT1F+yxmzFwmOfEoObk96p01evpcSOOquQ60 hLgjZzDRpb3/6KknamcccHQVzTMSnNRKUjhvJzUdBKdg8ddk3krC8CErE+djWsO5dtDh oryxSZll6H2R+fNBIRiD45d+I73YJ9nHuh0MukaiKXo9RcNF3V1v+SRBgpqGSaBLs5rC nrnik8WU9ftfOncFYXvVv8QvkM49gJKX9vAArIZXxRudJWeeHfl1uyzIESGWAUtsILOh /cR2XikqCDCo85qV26XKPY/Ds1O6VUdqJAzGdHDhumChxD+595VCcy8sbaXaI9Xyn1lo POtA== 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=9K0gcdyqyJc1QtOxbnGCoxSlcO9DFr3Tv4OE16b7cHs=; b=aKlOfd+Yr5D2uRe4U9YVmGPVNaWE6NTrKWExXC2zumQ2S+cdkWQB8o2IraS5UwawnY SOyh+dj7SXQk1i8FzwhsgfY1TTXwh92YHpGiZvu1d9GeHvNzupswE2RHwRpGG7AUSJue 1tJnhPu/wEUoIHBTwwSSPOSm4hamBx3qUc3cEmT891S8G1y2y4GN9wOZTTrRHXs8QGMc WRikFLIdPCkPjzTUIS7azApyOBAlhvSWZg3oMDgIGwvyJ6LAvFT5nQXe0NnClIFe8zfA 5DvQwn9i35TxHtr0UqMcSo2r+1ptyEEtMs9BN062nADUEDsmScEjPdV2AUyfCPUBqUMW JULg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KsliqEO2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a6-20020a17090a854600b001bf24ef7511si439960pjw.125.2022.03.08.16.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 16:03:10 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KsliqEO2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6A7A2DEA1F; Tue, 8 Mar 2022 15:37:10 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235928AbiCHRWd (ORCPT + 99 others); Tue, 8 Mar 2022 12:22:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348975AbiCHRUu (ORCPT ); Tue, 8 Mar 2022 12:20:50 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E5F19C07; Tue, 8 Mar 2022 09:19:40 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id qx21so40743456ejb.13; Tue, 08 Mar 2022 09:19:40 -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=9K0gcdyqyJc1QtOxbnGCoxSlcO9DFr3Tv4OE16b7cHs=; b=KsliqEO2BmgRd/JUjeCagekkSlvlnEeYkzi1XuFTJZc312pDytb0eYxrKEMnvYkH1X 5nRdaQnkab7c0r9kP8bCinM8AHhLYb4+jR2HSoBumHjNWHbVvPuXA3dQY1GNc0NsDgxz 2r1PahOgdidTf4Mldm1VVfZBp0GNjXWkNdvep/m2da0y4mNRBFmcbVXJNAuEWfYuYp9P Xu2xsoYrJrp9Dcbqv14oZvUZTO6nz7cVXz3Fky5Mt3NvcuKOrvEwcMOXl1Poc0ct0AIB laB6aMGnzn/9HFgXkbVf1jJMY0CNHl4+h9NIIx9GVtkjjzf33RDEHgtbaF/4XaJol/nj /peQ== 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=9K0gcdyqyJc1QtOxbnGCoxSlcO9DFr3Tv4OE16b7cHs=; b=J14wVZY/rDAc1q/qyejGtVXze5bB+V+9npGDlsS7lKzbCPR0Lf78PoHXK7DufoyY5R iDYEcE2lxf1jUrSpMDhz98hIRm9Qo2ilvbd7VH8EyqJJF72qXQRQGHjgnu0/Mux9GkJG oJXGs022w8FFfYD7rnMyvdr9gajl9pjlIen3mjRyCXNpRJw8dLqZH9jAnciONCRJWp4j VGZ2Aip3E0EJxbA4Kyeu/pLMt3ZEgWXa0mR6XMEd/jXUeKB/liqA8EP5u/rIFf44hLs2 u+3NaPaIMr7EmlQd1c2D1SgAWbd3UdgDFA/luVG1nbNQN8324l+Y0hv9lCEsLOwwvyCx b57g== X-Gm-Message-State: AOAM531JyshlifBdXCTR8R8rxw2Ixk/0S0lCQ7+sbGLGjxWZIzLPQwjk zQd2GgHpDmZAT7xCMqcOrmw= X-Received: by 2002:a17:907:168a:b0:6da:9167:47dc with SMTP id hc10-20020a170907168a00b006da916747dcmr14227765ejc.126.1646759979025; Tue, 08 Mar 2022 09:19:39 -0800 (PST) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id rv11-20020a17090710cb00b006d5c0cd5e0dsm6085044ejb.82.2022.03.08.09.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 09:19:38 -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 v2 25/26] usb: gadget: dummy_hcd: remove usage of list iterator past the loop body Date: Tue, 8 Mar 2022 18:18:17 +0100 Message-Id: <20220308171818.384491-26-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308171818.384491-1-jakobkoschel@gmail.com> References: <20220308171818.384491-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable [1]. Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/ Signed-off-by: Jakob Koschel --- drivers/usb/gadget/udc/dummy_hcd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index a2d956af42a2..35aec8e7fc73 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -751,7 +751,7 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req) struct dummy *dum; int retval = -EINVAL; unsigned long flags; - struct dummy_request *req = NULL; + struct dummy_request *req = NULL, *iter; if (!_ep || !_req) return retval; @@ -763,13 +763,14 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req) local_irq_save(flags); spin_lock(&dum->lock); - list_for_each_entry(req, &ep->queue, queue) { - if (&req->req == _req) { - list_del_init(&req->queue); - _req->status = -ECONNRESET; - retval = 0; - break; - } + list_for_each_entry(iter, &ep->queue, queue) { + if (&iter->req != _req) + continue; + list_del_init(&iter->queue); + _req->status = -ECONNRESET; + req = iter; + retval = 0; + break; } spin_unlock(&dum->lock); -- 2.25.1