Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3931766iog; Tue, 21 Jun 2022 08:39:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vxL5co2p7E2mKNz9lq5mMMkc//fWqMkoy1OevCLR9LlDyMaLXWPsKKBoJfztwWMdG08afY X-Received: by 2002:a17:90b:3907:b0:1ec:9225:6a81 with SMTP id ob7-20020a17090b390700b001ec92256a81mr18522331pjb.0.1655825996924; Tue, 21 Jun 2022 08:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655825996; cv=none; d=google.com; s=arc-20160816; b=M9qaAHqh9MpAZjxN1hE38+trJd4MIYk07ehb3phtogozVxrRIt+EnEEa7VTEb4H0S6 YN7AB2r2m8Wb4wLQlyReq6jhLzMyNLGciXnhmRlK3docAxHmbDN3eINJNt7PVPhDBi7f 2QQ6TP67bhFfsF4+3RZ8u/LcaaKCzPFt2HK2W0ISjXKwa79LGgeNQyEbwNecoO7kt2Zg rB95fDzwLNw16LUuaqLIJbxQa7bogrNOF+HxXOh66TDmxg1ESFsDn/r3ADMuaAjgo9cV qsAI7Nh4uf9xcfMRstnCkN0Zfr366ot6/6xRCytRwSX7vIZ1iIg2C6S+LOJql4L9AQ7w DFrg== 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=BeDBn8LeOb7JeklimGiqgq8xZ/lXczH0zoKomAlW4mI=; b=qohol1sR3+s0fRr5lvq2x7csmSKb8L6wDmQvUlcX8HYY1dIxrG0Xnw4k8rh9koWGFx 6QLvu3MJNSpPQnnbOyVna3F3JnDxV2ZWI3nS4WVeA7nAO9EGPjLS+eWoGIpFF44W1JrB ObxgbH5+TzN4gV+00yweMz6dSzmf0klkP1/ZB7GGsgSB5OltSXozfjaOtioCa0ViMhsI /TkvuJGaYwf90bYoSae2OT72v4eMFOk3c95DpMllsnmAGmPtzQuGMj6UEkNdOWmSn8K4 zIgy3QFIU4AzyoTk0gihkR812iwU4uaMN902zT3PrROuN18rGgFEHz/f31qa2gK04Z+Z m8GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jhiRfWMm; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170902d51100b0015f0bce1a31si22265399plg.558.2022.06.21.08.39.43; Tue, 21 Jun 2022 08:39:56 -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=@kernel.org header.s=k20201202 header.b=jhiRfWMm; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352845AbiFUPhF (ORCPT + 99 others); Tue, 21 Jun 2022 11:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352221AbiFUPgt (ORCPT ); Tue, 21 Jun 2022 11:36:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8195415A04; Tue, 21 Jun 2022 08:36:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 215E3617B9; Tue, 21 Jun 2022 15:36:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 485F2C341C0; Tue, 21 Jun 2022 15:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655825807; bh=BFgf0zqrAMHCzVhB0LR42v1zFL2DGd2X7e3aolkhaXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhiRfWMmud5IBjJj1VRrPb3nFB7VeIgRBahTWYFInw1IjYOSEcxHy9IbJDByqYeoD VMFTOrvkZHbRj6asGKWR8F3YqtyfEjlEmefqnuX/apT+4tQA0m3YJX2Jr2haaEfbiw 8aIfNp2OJue1ldpiJ3idu6QcEMDHhygTpsKgaBebdg9uVghqYwnuhaQBUCENBVhLxZ uiJAmGIqLe+42GjH6v9kA4uolsLqIYgvzNQSoEzp+Dsc7GupRrfEivCQfk2xjbjGij sifWMhPkTJRCBVo5cB666GlRVqShOI/ECUw2MDafby61l23lJ1prIsSie0sqH+ExAO dOqdvb7Am/I8A== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , Matthew Garrett , Peter Jones , Tony Luck , Kees Cook , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: [PATCH v2 6/9] efi: vars: Drop __efivar_entry_iter() helper which is no longer used Date: Tue, 21 Jun 2022 17:36:20 +0200 Message-Id: <20220621153623.3786960-7-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220621153623.3786960-1-ardb@kernel.org> References: <20220621153623.3786960-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3578; h=from:subject; bh=BFgf0zqrAMHCzVhB0LR42v1zFL2DGd2X7e3aolkhaXg=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBiseVwIqcpwelyfxmZMoxYNwsSZIUcY7u1TlZrlFba KjdWVCWJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYrHlcAAKCRDDTyI5ktmPJN/1DA CvJFfIIf5ul+iaiIMOluoj6pvU5WdNmXTc+z+KXe0Z5fISbB5+OGr98LeNotRHeaA5I/akzWd6EAaw EypCpywYWaFKy4WlQ0tavLje+H5Gyd0D6KHZQVELGu+Vxwhid+gGJidPTRAvBSSDD/5Neeyn7vZotj nDeQTe7l16ajLllish14clPNPGbVYHNXbb3k1BKJi+qXJ8pzcn6EiqvEx9rksjr8dj4kU075MhQKDD 4pnS2BSXgEDYpvNAyjVTQMH6VhTTSl0Fn2eaZB4fPbmyts7HcgyihSG+lVQpcR/r6y604fnyigCQ4w WH1vrCFSc4eB7mac6RgyMw2dHjjyL776I1P2hRhNwS7ZsUMg5ZB8z8MRxw/F4ECBWpQ08236hNbkN6 5nTD2uB/7RsjJ8Wh14bAvc3XQeuK5CgXjLzOlpy7K0QE2wmwH1osx/Hz5Cqcc65WJjIk/PW3gYiKiC 6Lb/HjO8UQyHtZxHHNe8JEqcst3f+F/DiS4huSVhPJ2r8= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 __efivar_entry_iter() uses a list iterator in a dubious way, i.e., it assumes that the iteration variable always points to an object of the appropriate type, even if the list traversal exhausts the list completely, in which case it will point somewhere in the vicinity of the list's anchor instead. Fortunately, we no longer use this function so we can just get rid of it entirely. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/vars.c | 61 +++----------------- include/linux/efi.h | 3 - 2 files changed, 7 insertions(+), 57 deletions(-) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index 29540013b358..932435945c85 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -1034,59 +1034,6 @@ void efivar_entry_iter_end(void) } EXPORT_SYMBOL_GPL(efivar_entry_iter_end); -/** - * __efivar_entry_iter - iterate over variable list - * @func: callback function - * @head: head of the variable list - * @data: function-specific data to pass to callback - * @prev: entry to begin iterating from - * - * Iterate over the list of EFI variables and call @func with every - * entry on the list. It is safe for @func to remove entries in the - * list via efivar_entry_delete(). - * - * You MUST call efivar_entry_iter_begin() before this function, and - * efivar_entry_iter_end() afterwards. - * - * It is possible to begin iteration from an arbitrary entry within - * the list by passing @prev. @prev is updated on return to point to - * the last entry passed to @func. To begin iterating from the - * beginning of the list @prev must be %NULL. - * - * The restrictions for @func are the same as documented for - * efivar_entry_iter(). - */ -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; - int err = 0; - - if (!prev || !*prev) { - list_for_each_entry_safe(entry, n, head, list) { - err = func(entry, data); - if (err) - break; - } - - if (prev) - *prev = entry; - - return err; - } - - - list_for_each_entry_safe_continue((*prev), n, head, list) { - err = func(*prev, data); - if (err) - break; - } - - return err; -} -EXPORT_SYMBOL_GPL(__efivar_entry_iter); - /** * efivar_entry_iter - iterate over variable list * @func: callback function @@ -1104,12 +1051,18 @@ EXPORT_SYMBOL_GPL(__efivar_entry_iter); int efivar_entry_iter(int (*func)(struct efivar_entry *, void *), struct list_head *head, void *data) { + struct efivar_entry *entry, *n; int err = 0; err = efivar_entry_iter_begin(); if (err) return err; - err = __efivar_entry_iter(func, head, data, NULL); + + list_for_each_entry_safe(entry, n, head, list) { + err = func(entry, data); + if (err) + break; + } efivar_entry_iter_end(); return err; diff --git a/include/linux/efi.h b/include/linux/efi.h index 54ca2d6b6c78..93ce85a14a46 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1083,9 +1083,6 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes, int efivar_entry_iter_begin(void); void efivar_entry_iter_end(void); -int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *), - struct list_head *head, void *data, - struct efivar_entry **prev); int efivar_entry_iter(int (*func)(struct efivar_entry *, void *), struct list_head *head, void *data); -- 2.35.1