From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web12.105.1582675216877019496 for ; Tue, 25 Feb 2020 16:00:17 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KxPW+JKX; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582675216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HPVXe32EWiqvUewaPhovWvdtPl4kEV2x02p2VoDUd/s=; b=KxPW+JKXgnudmxtl0iZ4fxDNrhwOg6tgnaTvls7uzWfXrhikBE9iOWjoBBqYc5gWU897e7 pBamoWd6y6itEbOwtAmFnhcmSykyspI85/FkgwiHr73QSvtpQzrKMF1dzKCsajKH/cIuxQ 7DJgIV4/eYZQrCTgH+ACsfBdG8QqiOs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-xrg1b2X4O1WlITBt9gXA9w-1; Tue, 25 Feb 2020 19:00:13 -0500 X-MC-Unique: xrg1b2X4O1WlITBt9gXA9w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA047100726D; Wed, 26 Feb 2020 00:00:10 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-104.ams2.redhat.com [10.36.117.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC5228C077; Wed, 26 Feb 2020 00:00:02 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 2/6] OvmfPkg: add 'initrd' shell command to expose Linux initrd via device path From: "Laszlo Ersek" To: devel@edk2.groups.io, ard.biesheuvel@linaro.org Cc: leif@nuviainc.com, pjones@redhat.com, mjg59@google.com, agraf@csgraf.de, daniel.kiper@oracle.com, michael.d.kinney@intel.com, jian.j.wang@intel.com, hao.a.wu@intel.com, ray.ni@intel.com, zhichao.gao@intel.com References: <20200225093908.6707-1-ard.biesheuvel@linaro.org> <20200225093908.6707-3-ard.biesheuvel@linaro.org> <2192beca-d8af-beae-cf72-ba63ad0883f7@redhat.com> Message-ID: <4c035460-20c2-11b3-5d41-05f896af4c34@redhat.com> Date: Wed, 26 Feb 2020 01:00:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <2192beca-d8af-beae-cf72-ba63ad0883f7@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 02/26/20 00:43, Laszlo Ersek wrote: > On 02/25/20 10:39, Ard Biesheuvel wrote: >> + Status = ShellOpenFileByName (Filename, &FileHandle, >> + EFI_FILE_MODE_READ, 0); >> + if (!EFI_ERROR (Status)) { >> + Status = CacheInitrdFile (FileHandle); >> + } >> + if (EFI_ERROR (Status)) { >> + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), >> + mLinuxInitrdShellCommandHiiHandle, L"initrd", Param); >> + ShellStatus = SHELL_NOT_FOUND; >> + } >> + ShellCloseFile (&FileHandle); > > (13) If ShellOpenFileByName() fails, it seems to set FileHandle to NULL. > > Can ShellCloseFile() cope with NULL? > > FWIW, its sole parameter is not marked OPTIONAL. I missed the extra indirection here for a minute, sorry about that; the question still remains whether ShellCloseFile() can cope with (*FileHandle) being NULL. Thanks Laszlo