From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kWgPI-0000Bz-Fn for mharc-grub-devel@gnu.org; Sun, 25 Oct 2020 09:50:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kWgPH-0000BB-Co for grub-devel@gnu.org; Sun, 25 Oct 2020 09:49:59 -0400 Received: from foss.arm.com ([217.140.110.172]:38956) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWgPF-0005wO-Jo for grub-devel@gnu.org; Sun, 25 Oct 2020 09:49:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D9D2B1435; Sun, 25 Oct 2020 06:49:56 -0700 (PDT) Received: from e123331-lin.nice.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 754153F68F; Sun, 25 Oct 2020 06:49:55 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: Ard Biesheuvel , grub-devel@gnu.org, daniel.kiper@oracle.com, leif@nuviainc.com Subject: [PATCH v2 2/8] loader/linux: permit NULL argument for argv[] in grub_initrd_load() Date: Sun, 25 Oct 2020 14:49:35 +0100 Message-Id: <20201025134941.4805-3-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201025134941.4805-1-ard.biesheuvel@arm.com> References: <20201025134941.4805-1-ard.biesheuvel@arm.com> Received-SPF: pass client-ip=217.140.110.172; envelope-from=ard.biesheuvel@arm.com; helo=foss.arm.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/25 09:49:53 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2020 13:49:59 -0000 grub_initrd_load() takes a char *argv[] argument which is only used when an error occurs, to print the name of the file that caused the error. In order to be able to split initrd loading from handling the initrd command, let's permit argv to be NULL, and fall back to the file names recorded in the file handles. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- grub-core/loader/linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index 3fe390f17ec6..8c01381778c6 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -317,7 +317,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, { if (!grub_errno) grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), - argv[i]); + argv ? argv[i] : initrd_ctx->components[i].file->name); grub_initrd_close (initrd_ctx); return grub_errno; } -- 2.17.1