Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1157394pxb; Fri, 1 Apr 2022 06:13:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzffxyNvtI8MWCe2JDjjyGKw8R8lCQ6nLraZO5T7/84H7oV8C8uWBb9nLlKIktEcWHh/3A4 X-Received: by 2002:a05:6402:40cb:b0:419:42de:65b6 with SMTP id z11-20020a05640240cb00b0041942de65b6mr21353591edb.66.1648818809895; Fri, 01 Apr 2022 06:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648818809; cv=none; d=google.com; s=arc-20160816; b=0IdAvNT/QiUnSo+fAg3tExdTX8S4oKWREsI/moUdxU5U6knCeAtYOzhtIEhPOjSteb DibzC4ecwQcXpyBaduYVvz7Yc6NloBmkVoSVg9SWk1pCikg7pAEPnqrbAnJt/+EZkIIu XmyNiuH6hIx49l6Bgnp6qJevsC+KHynh0hiP4tnl1HJlv3B/N8F0W3mA+/YjnERD6Ms0 xqHdou4rBB7wSqTR1yK4Tc1qzf4sznk6BDoVnXDBG1ZhYrcFVLup0dPPlPVfOSEJMx7c R1iWdALmohdir/nxMIzH9IV66WDm9pIbj3ClbfYBfzY06mnzHj5DflevR45Rszbww/f8 EEjg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=DvaX5NXvnnhCONDjD2TggHPkVfcRk9lluokmAGVTnZM=; b=Y4tbpj+wCnIKir5qCXg8p2IMxkiGWh+7dt+S/dXl/pNG2bMRJMzl1wkx9eJ7lZPyux nQPUHo6Oi+vhpyH6KD8cOj6gS5xVkpMKHGfi/3p0RwZNT31JgHm9JZwJtsYH9+ZmBc+Z R9RkOQNK/IrQHDsLMq2FUIT6b4YkssZiahGTSkaRLUk2WEnJwbzZjFzfCdYSGcb1Fgh0 MqQAJusCY7Jqq0ehNctUJ8A1eYFTqMT7BilCxiZrUouJp97N8shO6X5lJBIShaURpN0P OI90M3FvKsVXaDko53uGy/Bpn6RkDOQO6On79FjjxIoev4XCy/cTru+ihwidPsenR7EA fjzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ZMW4W/JX"; 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 bi2-20020a170906a24200b006df76385c0asi1485448ejb.170.2022.04.01.06.13.03; Fri, 01 Apr 2022 06:13:29 -0700 (PDT) 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="ZMW4W/JX"; 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 S242310AbiCaWNc (ORCPT + 99 others); Thu, 31 Mar 2022 18:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242292AbiCaWN2 (ORCPT ); Thu, 31 Mar 2022 18:13:28 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6BCF2467D4; Thu, 31 Mar 2022 15:11:39 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id c10so2036289ejs.13; Thu, 31 Mar 2022 15:11:39 -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:mime-version :content-transfer-encoding; bh=DvaX5NXvnnhCONDjD2TggHPkVfcRk9lluokmAGVTnZM=; b=ZMW4W/JXgOmdAE/uk7oLtCBZGANvEkTZm27+6vll59icGjEh1fmGtj9aHhF+N8VwWe cFImyl/m3yOuxHZf2mR+o6SqxnFrCk7PmuiTKnwhWSS4mMhMp8MhqK3+dxnFksGHc1f9 E7ao7/8B5qUyV+7zEKkTwcnPhXmeYwEAsKTo9hEfom5PMgh98phNWgamRIoeGTGvbr8u A6iICD5lPCAwiqMRDgxcI0OXWaB5gQA61TQwpxYCn1ox2tZdGYgklyfRXAcsjYxOPqE2 v4vKCcK8OAuzr11Q6MUj4xDVz9Llhn8evvyKM5jYcZKJAFLK7zmTkhphCPrKnhU1EnCd K8sw== 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:mime-version :content-transfer-encoding; bh=DvaX5NXvnnhCONDjD2TggHPkVfcRk9lluokmAGVTnZM=; b=DRIA3f0P4GeCLEEOjcrCSVXX/tDIgTrWRkVGQvUmLGvYYWQBsOoC5eOEUwkdCP96GX +ff46RcCUqYfHxogHoYcu/gj4ao/UofGhHfDkSYUgnb+todJiIDs/df+jmKGQraKsbQA CawSU2DUPU9rqHqaO4Td6QSmVnEgDa/2tSXm03NwvYdULr/OpN3aQdEjBlt31x5xJude TkxktPkaVyknVRDP+/z28J6DzoFoJwu8pFSjpc0v31sX4A2Gqx/YDBkWh7mQ7JuwOalM 4+fTmJOZzlVqLZ1vAf1iWmmwTOW+CDPVcx4uoJB0R62qRkcCbMFtF3xXlRqFBvw7ilnv AXLA== X-Gm-Message-State: AOAM531ZhvpmAATvbHX1Py7PXJ6jqeB1y1oR4J9DTDlr/I8AUvUXoVBX niMwGaWD3N81Z2FzcQ/FAMo= X-Received: by 2002:a17:907:c16:b0:6da:7d72:1357 with SMTP id ga22-20020a1709070c1600b006da7d721357mr6718359ejc.251.1648764698305; Thu, 31 Mar 2022 15:11:38 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id z6-20020a056402274600b004194fc1b7casm321322edd.48.2022.03.31.15.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 15:11:37 -0700 (PDT) From: Jakob Koschel To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH 1/2] efi: remove use of list iterator variable after loop Date: Fri, 1 Apr 2022 00:10:29 +0200 Message-Id: <20220331221030.889718-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 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 In preparation to limiting the scope of a list iterator to the list traversal loop, use a dedicated pointer to iterate through the list [1]. In the current state the list_for_each_entry() is guaranteed to hit a break or goto in order to work properly. If the list iterator executes completely or the list is empty the iterator variable contains a type confused bogus value infered from the head of the list. With this patch the variable used past the list iterator is only set if the list exists early and is NULL otherwise. It should therefore be safe to just set *prev = NULL (as it was before). Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ Signed-off-by: Jakob Koschel --- drivers/firmware/efi/vars.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index cae590bd08f2..3994aad38661 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -1081,14 +1081,16 @@ int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *), struct list_head *head, void *data, struct efivar_entry **prev) { - struct efivar_entry *entry, *n; + struct efivar_entry *entry = NULL, *iter, *n; int err = 0; if (!prev || !*prev) { - list_for_each_entry_safe(entry, n, head, list) { - err = func(entry, data); - if (err) + list_for_each_entry_safe(iter, n, head, list) { + err = func(iter, data); + if (err) { + entry = iter; break; + } } if (prev) base-commit: d888c83fcec75194a8a48ccd283953bdba7b2550 -- 2.25.1