Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1025385pxb; Fri, 15 Apr 2022 18:45:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQxAt+MgvdE0pXBmRiHkPeQhuGFRcEQQ/9wBuSVwgamAyA04SvaEvRi/MagFhn75EI3Tdt X-Received: by 2002:a17:90b:1a85:b0:1cd:7c49:3100 with SMTP id ng5-20020a17090b1a8500b001cd7c493100mr1693278pjb.124.1650073539820; Fri, 15 Apr 2022 18:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650073539; cv=none; d=google.com; s=arc-20160816; b=rfrcxPf+46QC5fnJraq9SaGojveRakj7WQU/GmjEpS7Xn+AmqVsLBMxpQqH50SOzxH qP1lfiLeJidbcniXGoP7gpX27aA2oDojM9+wz75PmADLO+pusqyKOv23IG3tfLcG07Id r/YGFMz+9/4uSgfYlU6PZkQMhlmOdYRdWzlkSZJNMmeBlvAbb58BZCQETThyHutpIWZW fzrgUFRdhzF48R+qOxojLWNVjX39bWwQv7hIUK32O+84phT9ZdvavGE2OT7RNuZ47iHC O5G2nBZh74ku5QvAfUZoM6T7//WtE4cYHsvw7xKIUZM5aSOr6Zpx3ycgztYT9OTrn1jo irwg== 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=fIZenjsGtzoZOCvRY/8dIr7NFNGibTLVVWT+oNYuIJo=; b=Uq2UgGSZJM3LiOhoaRfQxW7V//raKIRAlxR/LfnPC6mBTTR+ITeYXRzHtnDQT/F0ff bXfzmmpG/X7DMdMrVG7YIO8wZUT1kYG5hg5Flnu0cFz8JZROW4De8e/xsGqyRWGcOzFQ LEjK1mymttV5jIxvnz5Ns0P/LLDw7ayPxEd56iWNzMdp23JLODkgP2cfonLNqUf9oi+C l4/QGZnD5ntO6gm7yEXjZU+S44KAR8jHMJO7DwiIl5BWe7e2KsGSKnPkAW6KuNmkLDN9 RxLn6nG6ZP45Xv7U3+QGPrSchHPoDxw7MAIuouG4h5Jd5KfvuYKys/p4gCCr3mOyz4+e vb5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PnprkJEp; 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 s16-20020a170902b19000b00153b2d1641fsi2690779plr.39.2022.04.15.18.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:45:39 -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=PnprkJEp; 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D5CA9129244; Fri, 15 Apr 2022 18:09:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230226AbiDOMfD (ORCPT + 99 others); Fri, 15 Apr 2022 08:35:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344832AbiDOMdd (ORCPT ); Fri, 15 Apr 2022 08:33:33 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FE0B329A7; Fri, 15 Apr 2022 05:31:05 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id t11so15102319eju.13; Fri, 15 Apr 2022 05:31:05 -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=fIZenjsGtzoZOCvRY/8dIr7NFNGibTLVVWT+oNYuIJo=; b=PnprkJEp2AV/psDSMmNlNJR5/A6mm1H16/LpjoBjEuaix47jUPTOMi1cgCdR7PBn7X C7rCT7JJgTLtc33gKay7RC67B1NsptkBmDPqwCfInz0WENgKBqsDW4vFVMaOIC8dUclS /+oxUFIQWxH39M6uE0HzXos2C62iWdBQRjtYmp8K6IUVZdo+53+bkuwEuUfCd+sDo4xA qLoVbtxYwjSiBQ7jVpMwDObcu2HkSJrmHfv4hfHl0ktbZEtJhUgUwuSRnBnm+TRC9ETz v6/00UdmF6bhJopm36jbohFJEyRDAneLSE2ubDYHLeBKhXYUbTEdLuksjgw+vPlJZpub fCUA== 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=fIZenjsGtzoZOCvRY/8dIr7NFNGibTLVVWT+oNYuIJo=; b=WdsCBZvsAjnZdX5MOAgE+3s8x40TQKoF7HZsBFOfecdmctJprl0dKxkABpneJ0pfhX jvl9IXhEgF6w5APT99t+KFVqM97aRlTFsmlsas9KlLUMdZXd0/mhCYzD8/2QFs+ZcUjX 48+NZXzBpvBhVvhkSHC44Y96gSdgAMQgzqC3x5/Hm7xLrPhcCQ61JgIU4cMUWksKbLhI wZVnHOyrLZQW7qIyUtA3klhjRGNMBlNhs635AmvjhnvWe2CiZr/0kVHzeQvoSbefEcc8 VWop9E8+TBSq6NKxofcQcuPIRXKjdCGzqQSZCtizjNmSoez5hPilc+FQpbosSKblbrzy OopA== X-Gm-Message-State: AOAM532gB0xgGZeJ8bY0GUF40LZWN85iM2COPdzQPfOJeIQSGfGuFZGF TRJYtSPbgsmrWNg4ShL0gVE= X-Received: by 2002:a17:907:da7:b0:6df:9ff4:10c7 with SMTP id go39-20020a1709070da700b006df9ff410c7mr5945711ejc.106.1650025863925; Fri, 15 Apr 2022 05:31:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 05:31:03 -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 13/18] net: qede: Remove check of list iterator against head past the loop body Date: Fri, 15 Apr 2022 14:29:42 +0200 Message-Id: <20220415122947.2754662-14-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 When list_for_each_entry() completes the iteration over the whole list without breaking the loop, the iterator value will be a bogus pointer computed based on the head element. While it is safe to use the pointer to determine if it was computed based on the head element, either with list_entry_is_head() or &pos->member == head, using the iterator variable after the loop should be avoided. In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- drivers/net/ethernet/qlogic/qede/qede_filter.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c index 3010833ddde3..3d167e37e654 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c @@ -829,18 +829,21 @@ int qede_configure_vlan_filters(struct qede_dev *edev) int qede_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid) { struct qede_dev *edev = netdev_priv(dev); - struct qede_vlan *vlan; + struct qede_vlan *vlan = NULL; + struct qede_vlan *iter; int rc = 0; DP_VERBOSE(edev, NETIF_MSG_IFDOWN, "Removing vlan 0x%04x\n", vid); /* Find whether entry exists */ __qede_lock(edev); - list_for_each_entry(vlan, &edev->vlan_list, list) - if (vlan->vid == vid) + list_for_each_entry(iter, &edev->vlan_list, list) + if (iter->vid == vid) { + vlan = iter; break; + } - if (list_entry_is_head(vlan, &edev->vlan_list, list)) { + if (!vlan) { DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN), "Vlan isn't configured\n"); goto out; -- 2.25.1