Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp4693lfv; Tue, 12 Apr 2022 14:58:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx65AJlXMmHWcZ8IvLTC/m0K4+EH2tyU/m4qQHIv5PjbkPfP3vYBlzCofXYScGbAt156KyH X-Received: by 2002:a17:903:288:b0:156:a6b5:80d4 with SMTP id j8-20020a170903028800b00156a6b580d4mr40717865plr.98.1649800681938; Tue, 12 Apr 2022 14:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649800681; cv=none; d=google.com; s=arc-20160816; b=uZdbz2ez+yMBAL+lIqCaPqs+m7+tBB3MxTDdfxBUpQPMbSF/H+0fuzDwPO2HjJ6EEw jvNeT94zQC6F0aY0tKdmwS9kj4HZai5xluTVWRB5MOnjQfw3VZh8uRYWkCQBG/wmMDsM FKFKNNIdPt116fBX+v0EbgEl+coWI0Z6kGdUfvgsS7EasbeFn0tMpY+mxiMLihfBT7nw dOCkgsrMZ+RfsLhEinggWwvWLJkwRaWVlhztZiOhGKn3DmzDXlEErfeaSILkX/x6PMck MK8tBbeXY0legaAfP22XCmGka7u8kPIumjgK8ADZpOIDE00XuxRFOQQsSZSjoJiFCesF 8YdA== 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=yEn2KXl6YaWL8lEsoeTa0NhbbIFQf0W1A7EAGx1tWC4=; b=03xt+lEHoychZmr6RCwUxLBt1PLTT4S+JCF3kABOC8/TAgL1aEEFylMlayZcY+GCVv Hm/YukQDqadwYzo5gmh7v9hBRINeBRJnEzIPW5sXBH8xt5gecpAkKQPpCvuovctlOCop LpbG72wtooYYdpiypigOFo1hRLMqb9Gj6f+knkHh8+yxR+Iy7TpatBJ/EHXYqcdw1Yks kPEOsqO9iEXD80oSS+PymBqbvad5Z1vpDXQJGY+GvhXEQPTKVZaM2gYh1/3ALKAaecO3 HPQYFkQkj2HZimvGbb22AQq7Pv3rIgmcCcgBuew1UGddhHUReifdeirnVQhot6LF8Vz9 N7Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iXJMdwpN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w191-20020a6382c8000000b003816043ee1asi3961411pgd.15.2022.04.12.14.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:58:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iXJMdwpN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 30D2412D0BB; Tue, 12 Apr 2022 13:50:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233679AbiDLMzM (ORCPT + 99 others); Tue, 12 Apr 2022 08:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355312AbiDLMsK (ORCPT ); Tue, 12 Apr 2022 08:48:10 -0400 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 DEB95DFEA; Tue, 12 Apr 2022 05:16:48 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id i27so36939014ejd.9; Tue, 12 Apr 2022 05:16:48 -0700 (PDT) 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=yEn2KXl6YaWL8lEsoeTa0NhbbIFQf0W1A7EAGx1tWC4=; b=iXJMdwpNrxt7RXikTigM+URh+seDNwmTBeP54jN6oatM9hD1I1qjtOAyt6rGEXqP15 cpcE0OlWaDY8NarYxMocprMaFJZx8nqBB2tW6LPkyAV9+i4IlC3n9Z+vheu/faQaFbJs xNt4I7wFDeNIaqRsGQbGhPfy5tmM2/JNonlVMZ5sLYkcDgctqeb2aNmgeh9Vrry/Hr64 7VxLVBOINIG/PyrTnB0EBKGmYHymLdoGlhkoNDatkk0Qs5zabcqaKMO9ig8hNQX0WfLR aZYpNg/1B/WDrNUbgOAO5y7K/M3WCiYcVFCODA+3dUppRLfb71j1kLsKBQgJ1deOiAQy ja6Q== 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=yEn2KXl6YaWL8lEsoeTa0NhbbIFQf0W1A7EAGx1tWC4=; b=smz9p2C5nJp4095IqxV2XYc/jfwr8fQ816aGpCSrc8a200tUfkIrY05aRz+6EqjwBP byaTTJMsvWNeP944/09q2mCMzODgiozdCrljM89HwlimbhazadCPG9smFJJFq9Y1cWUv +c57278/LmVJ9io4OCR7wktsj2uIy8iqybcRlfPIPbZ2WJor1k/JiZd9rNXx6K/B5GmD zf/2crPsAETOHEFuNYWBwuWzCs4nttya6N7PNTH2U8+nPzJP7Gi1Qvg3P8AjEa2yurXR OP2kHoLFsEJt28oJ+WFWl9dz+AxitLSs1q3NMpOOzqaSAQkD7SPn5XFmj/I64RHDrmnJ K4ow== X-Gm-Message-State: AOAM533xBfgB1spc6LWQg+bGpbEh6RzskVQLhFhOOnCTVvqtCe6FNYPI mTgH3R85ozGeZYSO61YBspk= X-Received: by 2002:a17:907:168a:b0:6da:9177:9fdd with SMTP id hc10-20020a170907168a00b006da91779fddmr34596105ejc.757.1649765807446; Tue, 12 Apr 2022 05:16:47 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id b5-20020a17090630c500b006e8044fa76bsm8827900ejb.143.2022.04.12.05.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 05:16:47 -0700 (PDT) From: Jakob Koschel To: "David S. Miller" Cc: Jakub Kicinski , Paolo Abeni , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Ariel Elior , Manish Chopra , Edward Cree , Martin Habets , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jiri Pirko , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Casper Andersson , Bjarni Jonasson , Jakob Koschel , Christophe JAILLET , Michael Walle , Jason Gunthorpe , Colin Ian King , Arnd Bergmann , Eric Dumazet , Di Zhu , Xu Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, bpf@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH net-next v3 17/18] ipvlan: Remove usage of list iterator variable for the loop body Date: Tue, 12 Apr 2022 14:15:56 +0200 Message-Id: <20220412121557.3553555-18-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412121557.3553555-1-jakobkoschel@gmail.com> References: <20220412121557.3553555-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 In preparation to limit the scope of the list iterator variable to the list traversal loop, use a dedicated pointer to iterate through the list [1]. Since that variable should not be used past the loop iteration, a separate variable is used to 'remember the current location within the loop'. To either continue iterating from that position or start a new iteration (if the previous iteration was complete) list_prepare_entry() is used. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- drivers/net/ipvlan/ipvlan_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 696e245f6d00..063d7c30e944 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -9,7 +9,7 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval, struct netlink_ext_ack *extack) { - struct ipvl_dev *ipvlan; + struct ipvl_dev *ipvlan, *tmp = NULL; unsigned int flags; int err; @@ -26,8 +26,10 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval, flags & ~IFF_NOARP, extack); } - if (unlikely(err)) + if (unlikely(err)) { + tmp = ipvlan; goto fail; + } } if (nval == IPVLAN_MODE_L3S) { /* New mode is L3S */ @@ -43,6 +45,7 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval, return 0; fail: + ipvlan = list_prepare_entry(tmp, &port->ipvlans, pnode); /* Undo the flags changes that have been done so far. */ list_for_each_entry_continue_reverse(ipvlan, &port->ipvlans, pnode) { flags = ipvlan->dev->flags; -- 2.25.1