Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp43484lfe; Fri, 15 Apr 2022 18:34:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTczVurWZEgu8w4HzJD7s6l8cyPrCjrF8Wesl+HIg7ENK2p0MR+wLcSM/VAT5FafaA1QAl X-Received: by 2002:a17:90a:aa8a:b0:1c9:bfd8:9a90 with SMTP id l10-20020a17090aaa8a00b001c9bfd89a90mr1682847pjq.118.1650072883379; Fri, 15 Apr 2022 18:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650072883; cv=none; d=google.com; s=arc-20160816; b=kNtI7XKjcmit85GSQDqODQRsYXFc4HUA4g9O7mzg4aybWUdDe1IiPVvHo2FD55vRaW MUANqt/l87WNBrnobb2qO9UuFByvti7TBgD5btIG4WleG0U0dakG9YaSCYQED5UCUPPl VSNGeCwi8BPXgIINK1qVJoM5dr7lPvMsoHwuYbM8oYqznv5B0uIVNnjvWrsvWP8EEQcd wfinLwdykE+jXM7dxnhrKtAjvyV/JWPCprZyhOWLaT/Gpr19rM6JxWkhM/Oo9Jx1Fqa8 SE4xwEQoUSB7bDS3frjWyYVaS6R9fQPtfedgJVs5I/AA6my++61RJ11EvFLqobqqjU3m 4wZQ== 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=y7By3R1UBoz5mH8o+7mVRG62/koODV8Okxco4fyMVVoIzn1eBRVIB+6ENaPiXG4f01 VKiEtPBKRr/ZnTXHuz/ReluXYDjqCkorApr4BU/wnmAjva3qD4I0VSYYtgt1hmqTZmgL FVywSsiK7/gFRdfYlbdFh4pG/wM1Hv1DaULdNsmizr/fYDfsJqxNHYzAi+E9KaQcdWaa vwRQju0+VkyRzaoxaKLj/muovgLJGV/qpYLbs7FSnl38VwSJd+BbDAb4eGacGp4/NcyE Uu4em7Vsa1dVDTB5gtecKAn4E5b82K2qb60zaft0jBTMFYflmeKioahuR8rgrOENxgtS QRAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b3hc5PlQ; 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 g1-20020a1709026b4100b00158200656b6si2589195plt.140.2022.04.15.18.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:34:43 -0700 (PDT) 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=b3hc5PlQ; 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 DE2D7158577; Fri, 15 Apr 2022 18:01:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353653AbiDOMfZ (ORCPT + 99 others); Fri, 15 Apr 2022 08:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353434AbiDOMdj (ORCPT ); Fri, 15 Apr 2022 08:33:39 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D93F252E4C; Fri, 15 Apr 2022 05:31:10 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id z12so9795415edl.2; Fri, 15 Apr 2022 05:31:10 -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=b3hc5PlQNJwnipmFgPKwKobkYuBqu+VhbGWKUONdb7h8D0d0QpzlgKH51PWjk95WTj ADJ4mluAmAow9uamrXzOVaO9sedPih8JXQg90Vp3D1U92O6F899Tf10rxWd7mAQjHEQA Szl5d9kjQph2s2n7ZeS5O3MZOHbMGtfCwoSSDSjugBjqNC9T4FwaS+WJ27MLXp8aIGVs DStAyL1wpAzpwElDS8FsoZW3S0OtwFzTPi8FKiZu1nwZMkCYJFTcEzRuXgZEBCkvC2DF h85SkTuD2SDpZQrDmEoOr3Eq95jeyRza5A0Porbl8XGQU+vuJ1UPBCPW5+GyonbvM5KD kwWQ== 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=EB6YUtloTLDhzvM8XkR4JBQwYonwdMtBFVdzYA+6WqIeUT4YsyLIlh3po/h9e4cEu3 qPbD7hfnNXsDDLCO/i+sfpBlQdwllMyJvRQIxEGMHw2AhbNyQVQWxt8dJRDS2WeHVt+P 5HtZp+dCqPMdBr6P5IF4H288nXvoMTeYPOTngpX0BKmS7LcaKlJIm9ssOMWv/Hj/+mks eEKG2hcCppjJWDgZ4FjeV0lRdJAts4Qc6akBs5cIBususpFDoNiJIdiuMZ6jocuWvGQi 4DE+5btg9243WqSg4LZVloY1lf2kO4Km6n61Ej0cIX9PEjetrkdrLHUabVI9MOhXZ9Vy GQSg== X-Gm-Message-State: AOAM532cHyo1Rd24+JoWd0uTv0QrFDVmqN7kVchxI5GmydY9io56wDqV tE/j/QSgGlqTx4F0SS0+yok= X-Received: by 2002:a50:d613:0:b0:41d:71bb:4af3 with SMTP id x19-20020a50d613000000b0041d71bb4af3mr8166908edi.99.1650025869469; Fri, 15 Apr 2022 05:31:09 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id bo14-20020a170906d04e00b006ce98d9c3e3sm1649533ejb.194.2022.04.15.05.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 05:31:08 -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 , Arnd Bergmann , Colin Ian King , Eric Dumazet , 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 v4 17/18] ipvlan: Remove usage of list iterator variable for the loop body Date: Fri, 15 Apr 2022 14:29:46 +0200 Message-Id: <20220415122947.2754662-18-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220415122947.2754662-1-jakobkoschel@gmail.com> References: <20220415122947.2754662-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