From patchwork Fri Oct 23 12:08:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 293126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EECC6C4363A for ; Fri, 23 Oct 2020 12:08:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97F2B20EDD for ; Fri, 23 Oct 2020 12:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S463441AbgJWMIe (ORCPT ); Fri, 23 Oct 2020 08:08:34 -0400 Received: from foss.arm.com ([217.140.110.172]:50728 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S463439AbgJWMIe (ORCPT ); Fri, 23 Oct 2020 08:08:34 -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 9FBC9142F; Fri, 23 Oct 2020 05:08:33 -0700 (PDT) Received: from e123331-lin.nice.arm.com (unknown [10.37.8.102]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 197FB3F66B; Fri, 23 Oct 2020 05:08:31 -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 1/4] loader/linux: permit NULL argument for argv[] in grub_initrd_load() Date: Fri, 23 Oct 2020 14:08:22 +0200 Message-Id: <20201023120825.30466-2-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201023120825.30466-1-ard.biesheuvel@arm.com> References: <20201023120825.30466-1-ard.biesheuvel@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org 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 --- 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; }