From patchwork Thu Nov 29 17:12:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152415 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2634041ljp; Thu, 29 Nov 2018 09:12:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WhPomC3Jxu6x6kVCFGnCl5/jtWteVdEp+xSYhIJXXjZWex8X00In9EHX+NRUE8GffViZjB X-Received: by 2002:a17:902:6948:: with SMTP id k8mr2246667plt.2.1543511578212; Thu, 29 Nov 2018 09:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543511578; cv=none; d=google.com; s=arc-20160816; b=X8HmRU7WrGdkWPicShXeC62mFPw351dTtjAXOS5xj8lNFXWubcvc7ZM6welNzHHYSE CBSjPP48IkN+2H9p++GI8/d0aookJcuJIBJuXBSbNDOhBLIbCNvV+SHAacWVAuIHMVW3 Sk6TDPFbNpWlWRnONNbbEp6tG3Y5dN7FpstVtq7xx7sh0qDF0Gp21OhDLxzq74izM1Qj GkPzXwYNVKaA/XCkgxjRU1VwcrRVfEjWTjXvp0JyiPkk0l/nlZZGIrHBgq6YraYIByTL zJoa0/FwvhTW2iil/eRRvBATJKGghMljAbQ9MGu+jmmK4KO7RmC9FOU8GEvLG/aiB5Lu lz6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Waq/8fI6AT262jsKSvQj9K7UesrlRkejH4UAHjKMNCA=; b=J77sMFYwDdFy2nt/CR+D86UL5TTLC87kDKA9NuXFesB9sBqp6DaVOm/zlQKXvCWQVH dDhk564RfwPKCN9Djvnpfo8WwEA5e0uvjsdx+dn7D48qOew6gpNO+W9Oonpc/DVner5D GtuupNw50QApmQ6uEj4LPsPIu7uq+KOZF+qPqQFvUJZauaUiUBVO7cndYvvzr6omdHDI ayfqZv0BcPX36Wse0mRSJUIGLB3Xbg6VDroBbAjqqKTOVF83B/KOgJyYvuNQxdDTj579 FCFH9fZcB/a/PJ4ZBMrIa6LgDtaA9c6Rjd9csfdf3o3QKREoj9AMx7SrvUvcY8YNUQCE cC1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Uc4XkjOY; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e63si2360810pgc.239.2018.11.29.09.12.58; Thu, 29 Nov 2018 09:12:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Uc4XkjOY; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730512AbeK3ETB (ORCPT + 3 others); Thu, 29 Nov 2018 23:19:01 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38120 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728255AbeK3ES7 (ORCPT ); Thu, 29 Nov 2018 23:18:59 -0500 Received: by mail-wr1-f67.google.com with SMTP id v13so2679268wrw.5 for ; Thu, 29 Nov 2018 09:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Waq/8fI6AT262jsKSvQj9K7UesrlRkejH4UAHjKMNCA=; b=Uc4XkjOYHS6lq4IwDZn/uFWPGv7LiKhYHci8x235j3KyPlfRryVOQpYtC8dqYYOxcF T+jA1CSFiVwdadzUlxL+FPcGO/KUX2ReQPr3CTMogoETBAIgYuMdz3H25fARNHYpxk2f Y2S7AjhdFVPn3xDHr7QAqc+XLdVX3qy/R0dRA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Waq/8fI6AT262jsKSvQj9K7UesrlRkejH4UAHjKMNCA=; b=Beqd4lWFSIlorZHNn1HXLdm7ERUxeDA1teMsahUSZtMj5GAOdCNQRRxfgDaKBzrHOc UUsRsxBDztfTYxnKhC8LRSiFJd4FZJLHhz5GZNiqOaGUsG9zJSg/yb81fD3mzmpkjUV+ S7c/evejVU/4IOmH7vQQQTfqIEXroQNWHyxqn1xMtP75BJg/Ucf4Z6UWLl3SVQxNPvS+ lC+/zjVx/3AhjlHFiuOgvT2jeLab4vkScWzaMTdaGi4HfiINdgUkqTMrizM3tO9snThO sSo3iWEwJ1nyCFlLtP9b9eqMjIPG21XrapkBpnsuwZ+5i+WcThP+ORdBSsfsIai1OF/j 4yCg== X-Gm-Message-State: AA+aEWansRFkjy3xVdWK4tZdK5a4dmCwfFthDGPXpFoEd3TMkdo6nnW0 Ay79cZcLlBHSKTQp7zeST3P09nURdVM= X-Received: by 2002:adf:a50c:: with SMTP id i12mr2053360wrb.220.1543511573188; Thu, 29 Nov 2018 09:12:53 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:f070:d240:312e:9f99]) by smtp.gmail.com with ESMTPSA id y185sm1593882wmg.34.2018.11.29.09.12.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:12:51 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Andy Lutomirski , Arend van Spriel , Bhupesh Sharma , Borislav Petkov , Dave Hansen , Eric Snowberg , Hans de Goede , Joe Perches , Jon Hunter , Julien Thierry , Marc Zyngier , Nathan Chancellor , Peter Zijlstra , Sai Praneeth Prakhya , Sedat Dilek , YiFei Zhu Subject: [PATCH 03/11] efi/fdt: Simplify get_fdt flow Date: Thu, 29 Nov 2018 18:12:22 +0100 Message-Id: <20181129171230.18699-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129171230.18699-1-ard.biesheuvel@linaro.org> References: <20181129171230.18699-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Julien Thierry Reorganize get_fdt lookup loop, clearly showing that: - Nothing is done for table entries that do not have fdt_guid - Once an entry with fdt_guid is found, break out of the loop No functional changes. Suggested-by: Joe Perches Signed-off-by: Julien Thierry Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/fdt.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) -- 2.19.1 diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index a3614f9b5f75..0dc7b4987cc2 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c @@ -370,23 +370,24 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size) { efi_guid_t fdt_guid = DEVICE_TREE_GUID; efi_config_table_t *tables; - void *fdt; int i; - tables = (efi_config_table_t *) sys_table->tables; - fdt = NULL; + tables = (efi_config_table_t *)sys_table->tables; for (i = 0; i < sys_table->nr_tables; i++) { - if (efi_guidcmp(tables[i].guid, fdt_guid) == 0) { - fdt = (void *) tables[i].table; - if (fdt_check_header(fdt) != 0) { - pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n"); - return NULL; - } - *fdt_size = fdt_totalsize(fdt); - break; + void *fdt; + + if (efi_guidcmp(tables[i].guid, fdt_guid) != 0) + continue; + + fdt = (void *)tables[i].table; + if (fdt_check_header(fdt) != 0) { + pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n"); + return NULL; } + *fdt_size = fdt_totalsize(fdt); + return fdt; } - return fdt; + return NULL; }