From patchwork Mon Dec 4 21:28:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 844463 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="hOny0vTK"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yrJ1q5fgGz9s7f for ; Tue, 5 Dec 2017 08:30:07 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 56808C21DAA; Mon, 4 Dec 2017 21:29:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C0E83C22095; Mon, 4 Dec 2017 21:29:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 74B5DC22076; Mon, 4 Dec 2017 21:28:46 +0000 (UTC) Received: from mail-it0-f68.google.com (mail-it0-f68.google.com [209.85.214.68]) by lists.denx.de (Postfix) with ESMTPS id B7D95C21DC1 for ; Mon, 4 Dec 2017 21:28:42 +0000 (UTC) Received: by mail-it0-f68.google.com with SMTP id t1so16390624ite.5 for ; Mon, 04 Dec 2017 13:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=kPQoqzu6pKXDdcRgVm1iPAtJDLc6qJisKPk7SRuIHmw=; b=hOny0vTKtrSC0rCTD+c4/UoSYlaZUA8F1y3ctqwicwGgTxZQt4yhvd+I46VCkiUMRu kAhCgfMjOwZ86164FNcvLcxnVlA32DZEaBeLpPeC38v43aVAJeJdqV9f8UDXyXWVOTU8 KDDVQ1tsYyMQ7nMD735XPYp7PG+waKPT1T/LOytSB2hKYHWF5/cA3i3Ui9HgeTodvDtu 1xSEu4SeATkBSyUejl3pcELOh4+4sEVVAm3bUM7Mox1sVIoF2q52E0MyFK5jN0Ua5AHx fPsOriBFPmoHB120FmJUg6pGejo9vHErxPwzuc81a0Iz1SJTfNCVkWkcj4CPJYjyReAR zSQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=kPQoqzu6pKXDdcRgVm1iPAtJDLc6qJisKPk7SRuIHmw=; b=k+JfEtVFMzUES/9+8y/AqXwhjUBsTpP7amMrA9SqL6j9YEewERt3biNOEEiyaw1Gr6 0WO3bVGrIJGyr/SOEW08cBJuVvGKxGzvTxiV0/MoFV1OxrC4kZsTJ34TX5LTIom8D0YH gTFK7csK8xqr9+MBXDP0SoyjeqTXSKHqmZrWzQqZ/mdEIVGr/pnQR7IQwdF1wd8dQEf4 Vde6ZglSAdl8F9H6u+kMihGhUo1Nu+UhHUkn6Js7F1loLV+vofe4bRmdtVSwroMPvA5S +XTRB41O3nvIkqNbIGqDuHjZNE/dhvKd0dT1eD7X1HtatIwbCD0mCVQAN+uzdZqKJ8ot 57cg== X-Gm-Message-State: AKGB3mKw/XUYy4nghu0UX/izRHhcWdrSNhOWw0emtr6Jdrui+BADjsVG /1AT8iiVNsu6jNHnUGDpBZ4Xww== X-Google-Smtp-Source: AGs4zMa8b9ainki+xqzaLjXf2PnyBHpNUUBlttNTW+3rnHWudlPhuva4nkPzwTYom2CAVet0zY56Xg== X-Received: by 10.107.167.77 with SMTP id q74mr329575ioe.171.1512422921264; Mon, 04 Dec 2017 13:28:41 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:51dd:225b:4557:7c0e]) by smtp.gmail.com with ESMTPSA id e88sm4245307itd.14.2017.12.04.13.28.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Dec 2017 13:28:40 -0800 (PST) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 3E7CE143C41; Mon, 4 Dec 2017 14:28:39 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Mon, 4 Dec 2017 14:28:19 -0700 Message-Id: <20171204212832.130100-4-sjg@chromium.org> X-Mailer: git-send-email 2.15.0.531.g2ccb3012c9-goog In-Reply-To: <20171204212832.130100-1-sjg@chromium.org> References: <20171204212832.130100-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v2 03/16] efi: Add error checking for efi_init_obj_list() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This function calls a function which can fail. Print a message in this case and abort the boot, rather than silently continuing to boot, which will certainly fail. Signed-off-by: Simon Glass --- Changes in v2: - Change return type of efi_init_obj_list() to efi_status_t cmd/bootefi.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 17b26e6f4e..a2138f6075 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -25,11 +25,17 @@ static uint8_t efi_obj_list_initalized; static struct efi_device_path *bootefi_image_path; static struct efi_device_path *bootefi_device_path; -/* Initialize and populate EFI object list */ -static void efi_init_obj_list(void) +/** + * efi_init_obj_list() - Initialize and populate EFI object list + * + * @return 0 if OK, -ve on error (in which case it prints a message) + */ +static efi_status_t efi_init_obj_list(void) { + efi_status_t ret; + if (efi_obj_list_initalized) - return; + return 0; efi_obj_list_initalized = 1; efi_console_register(); @@ -43,12 +49,19 @@ static void efi_init_obj_list(void) efi_net_register(); #endif #ifdef CONFIG_GENERATE_SMBIOS_TABLE - efi_smbios_register(); + ret = efi_smbios_register(); + if (ret) + goto error; #endif /* Initialize EFI runtime services */ efi_reset_system_init(); efi_get_time_init(); + + return EFI_SUCCESS; +error: + printf("Error: Cannot set up EFI object list (err=%d)\n", ret); + return ret; } static void *copy_fdt(void *fdt) @@ -137,6 +150,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt, ulong fdt_pages, fdt_size, fdt_start, fdt_end; const efi_guid_t fdt_guid = EFI_FDT_GUID; bootm_headers_t img = { 0 }; + int ret; /* * Special case for efi payload not loaded from disk, such as @@ -211,7 +225,9 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt, "{ro,boot}(blob)0000000000000000"); /* Initialize and populate EFI object list */ - efi_init_obj_list(); + ret = efi_init_obj_list(); + if (ret) + return ret; /* Call our payload! */ debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry); @@ -313,10 +329,12 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) */ efi_save_gd(); /* Initialize and populate EFI object list */ - if (!efi_obj_list_initalized) - efi_init_obj_list(); + if (!efi_obj_list_initalized && efi_init_obj_list()) + return CMD_RET_FAILURE; + loaded_image_info.device_handle = bootefi_device_path; loaded_image_info.file_path = bootefi_image_path; + return efi_selftest(&loaded_image_info, &systab); } else #endif