Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1345667pxp; Sun, 6 Mar 2022 12:27:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqjfSMmzOdMYHk6wQlW+oMKDyQDre5NRRxyr7ZHU5xemnKOIRCGRP2YoaQ3zrRIHC3uPHr X-Received: by 2002:a05:6a00:14d1:b0:4f1:76e:d952 with SMTP id w17-20020a056a0014d100b004f1076ed952mr9553083pfu.64.1646598444651; Sun, 06 Mar 2022 12:27:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646598444; cv=none; d=google.com; s=arc-20160816; b=XQVSGYOuSfqgSxaFDanq+TfYT0Xaw1tUbGJfb6A3C8HYF7/uvyz7JI78bZGZs9sO0Y 848LaTczCfXTvsFY6F+uHv+1aYGdxgRsSIEUO6Q7c6wQ70o+cq1kypieNauYZ5UseQCS Tiq80GddwKjo8vISKR3Nqq4qsbgDTVGSj4ERyQO8HNNO2gXqngzdK8yWZMo04fDQ1MzK 0gCqyamm0whGJCgbe0ySFA3EEmm/2NEZyMY4xO8ysxp7W5MXxpeLzyO5K//WhQELtt5K ttyrJes3hpZmdAWMxt8waqPtZ0ED8Bn2hm4w/0tqBu8Hr8jNUu5Hh9weCzuKJe9ZZ3fx IWOg== 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=f5+1KVl6xG8fB1kYFIuwRtTBn1Y4V5ASbbZ+diDolcU=; b=VspBeEwcLfbljFo1zDQmYeD+hfNfLBDMaw9H6sucf31nMZiDE9ypB9ot2UM42D2MZs goyvcq+qdn/q1tOZ6ec/WKEast9/JEtwTi4acbbpiFJLHQo4LbNFhb0hfOektFXIVVmW HKtEPKD8Pj4mLjm0rYOn+1G2qCj0k5XWPEh6VhlxLcrNHxywI+I0HYwClfspKREeu+10 fk/U+oSf/Mwiaesd+EfBCDwyMz+SA9S9o3Y7WaelBBa1Du/Za3bQgsqslph6Y41t9wCd lR2K2FeJ2zv1mfl0NOXUY/8wT53nik2HZpS4eWhmkyLp0yUVeci5msvbvu5Olk/FnQtU arog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ge0Bt7NZ; 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 h10-20020a056a001a4a00b004f41a2a6d4dsi11148657pfv.228.2022.03.06.12.27.05; Sun, 06 Mar 2022 12:27:24 -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=ge0Bt7NZ; 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 S233999AbiCFRwN (ORCPT + 99 others); Sun, 6 Mar 2022 12:52:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232643AbiCFRwI (ORCPT ); Sun, 6 Mar 2022 12:52:08 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 024B93E5F8; Sun, 6 Mar 2022 09:51:15 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id s1so16932675edd.13; Sun, 06 Mar 2022 09:51:15 -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=f5+1KVl6xG8fB1kYFIuwRtTBn1Y4V5ASbbZ+diDolcU=; b=ge0Bt7NZK1tqAmaS2XgbtreVorDpKfDnbik/79y+hzdYQPyOEQN0kNHebGiQ/Mmv7C 6GLlb/rz9tsv8K0LUXJrDm86ShdR2hWJIq2vK6epM8d0hgYCw+ijpOYEhuBzGyZ2p+xy NltSV4qWtiPYvxilTjeTqq/aluaaxdcASdQX+qoZciOj56uXEyN8ft/qKMMUkraYrvq1 TffadnFKU0tI3X6U8hJvIPZYMhFwfWTGtMpNklzpmRLg/atu+49rIfOWC4rtGlQcjKGE 60bk8ZP8xjj5ofC6WtjHDZ0PHL/YIyWGtbInNtb1TfdrttpHn7imcV0+PSfRutlAe0BU gSpw== 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=f5+1KVl6xG8fB1kYFIuwRtTBn1Y4V5ASbbZ+diDolcU=; b=GB6zh1mf/o6zStYN5s2+FnOvni7rAm8yjTlDnQcpF4TseZSd328m4rOsnH8YkL0Mrm xCWtrBjrfl37utoUN0a2+D9C/vCHFAxbhFRVJbCbqQ7m4wiQA1B8xON1vPMlKjF0oncU pUZssS/lZU0pX/A5h0VIyPqm1KM8RZJ+QVsttFWjCGzDorSpVktfGyy2+1zbDfD+BYC2 d2Quq4AcccGNe5PRhth9QIg2dcd2H6cqVEZOd6p9soz28uTeGtQU8w7q6tXWM+r4TAGc x1LORpbShzIPJ20LvDEHNa4hNweCPWQc7pktS7FGtIJSsIch/yL/GH1JEmkhoeMllnJt C9xQ== X-Gm-Message-State: AOAM533qieX4ftW/AqA4AubgZ/+Z47XNd/S6svCZGJtYNlQZC0rn4K9j 5s2OFLQV5f8O0Mc2/uIp5pM= X-Received: by 2002:a05:6402:1c02:b0:415:f555:38ba with SMTP id ck2-20020a0564021c0200b00415f55538bamr7566215edb.357.1646589074454; Sun, 06 Mar 2022 09:51:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Mar 2022 09:51:14 -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 04/26] usb: gadget: udc: pxa25x: remove usage of list iterator past the loop body Date: Sun, 6 Mar 2022 18:50:12 +0100 Message-Id: <20220306175034.3084609-5-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/pxa25x_udc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index b38747fd3bb0..889ea52bbe0a 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c @@ -966,7 +966,8 @@ static void nuke(struct pxa25x_ep *ep, int status) static int pxa25x_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) { struct pxa25x_ep *ep; - struct pxa25x_request *req; + struct pxa25x_request *req = NULL; + struct pxa25x_request *tmp; unsigned long flags; ep = container_of(_ep, struct pxa25x_ep, ep); @@ -976,11 +977,13 @@ static int pxa25x_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) local_irq_save(flags); /* make sure it's actually queued on this endpoint */ - list_for_each_entry (req, &ep->queue, queue) { - if (&req->req == _req) + list_for_each_entry(tmp, &ep->queue, queue) { + if (&tmp->req == _req) { + req = tmp; break; + } } - if (&req->req != _req) { + if (!req) { local_irq_restore(flags); return -EINVAL; } -- 2.25.1