From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1928C433F5 for ; Fri, 30 Sep 2022 01:47:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 432C4849F0; Fri, 30 Sep 2022 03:47:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="OVFYy41n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 23C19849AA; Fri, 30 Sep 2022 03:47:41 +0200 (CEST) Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 439A5849AA for ; Fri, 30 Sep 2022 03:47:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1029.google.com with SMTP id v10-20020a17090a634a00b00205e48cf845so7598387pjs.4 for ; Thu, 29 Sep 2022 18:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=cwSJ7AiSp+z2tpCjBrxKJc1lts3gye9lDbE2jyJAq8k=; b=OVFYy41nnAsxEII4Z01qjXtHhgwu6Vbktz3ZP9artX/e1jYLGmrC46lqCxqJXpjEqQ r6aKfNHYGSRMP9m994DSHZqhCHUEcvJtB1IQXaoiM57lchOv1VumDTx8YqTY0JL0wHG4 hDD91/IpFily0JWPZR2ZD37ncCJA2so5wtRQGgKCOn/AEqgevQuoVYS8V4+PW/w50UTd 6IDrQddlCi9veECo30F7zUcP3tVcyT1KS3Tqia5aaO+9pP/zeip8F18watbA71EjQ01E lMiK+WG2cz8CJ5FIGLwsnXxKlzGB4ZWeOeAwQBHe4qSOaRuNHIW1UszCWVYROa7kim/g 2T7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cwSJ7AiSp+z2tpCjBrxKJc1lts3gye9lDbE2jyJAq8k=; b=Sd1/dElkI+nxvpf9oCOYXfmPuhwRhbzZbtWkXv3x2L1s5iAn2gnn/LPV3tmjvYEI5L +dyIDCdYR7RqDj6KYpe3NYkATmMzBieiTC6zmwMu/iFcGKnZW69P7bxXpvfsw4KeNogt lOThpOZzexWrThZHemnrRj1A6gbRdMkOgIa6um2aALjym+7QBvlHm7ttrJzmydqF4UIM 1Yx9WSczc9QNVzQmDGTIJXSVjAQfLUMLrbwRT73xjDEs1nRuvtJef2XA4QBy/qjKojNT u1Arn6A4OxnD7exzDdK1gwteFIhaXMzQCZfChhFvEcdecedAGpXU7hVFMaxVrUA1hhGB YDIw== X-Gm-Message-State: ACrzQf2+OUeFpPffOOp6JOKcQ3irXjw8/LMtLaXRF5QYrRW1rHP5zat6 k4WC+9jNt2GbxiNq6qvxfBrZ1A== X-Google-Smtp-Source: AMsMyM5SaIBUkHJc+2t8vqo5lx7Qymew1efyNvwh6PApySOhCx5vS8DpISKlTh11j+geAIH5Mn/OpA== X-Received: by 2002:a17:902:ccc2:b0:178:29f9:5c5e with SMTP id z2-20020a170902ccc200b0017829f95c5emr6046101ple.21.1664502456027; Thu, 29 Sep 2022 18:47:36 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:53a5:1102:193e:47f0]) by smtp.gmail.com with ESMTPSA id e21-20020aa79815000000b00553b37c7736sm377217pfl.25.2022.09.29.18.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 18:47:35 -0700 (PDT) Date: Fri, 30 Sep 2022 10:47:31 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: Ilias Apalodimas , u-boot@lists.denx.de Subject: Re: [PATCH 1/1] efi_loader: fix efi_initrd_deregister() Message-ID: <20220930014731.GA10018@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , Ilias Apalodimas , u-boot@lists.denx.de References: <20220929235748.25608-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929235748.25608-1-heinrich.schuchardt@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Fri, Sep 30, 2022 at 01:57:48AM +0200, Heinrich Schuchardt wrote: > Don't try to delete a non-existent handle. It is okay as a safe guard, but it doesn't fix underlying issues. efi_initrd_register() is called only in efi_bootmgr_load(), and so efi_initrd_deregister() should be called only at the paired location. - Remove efi_initrd_deregister() from do_bootefi_exec() - do_efibootmgr() should look like efi_bootmgr_load() do_bootefi_exec() efi_initrd_deregister() Otherwise, do_bootefi_exec() always tries to free a handle in the other cases (i.e. bootefi ). Another issue is there in try_load_entry() called by efi_bootmgr_load(). (after efi_initrd_register()) if (size) { *load_options = malloc(size); if (!*load_options) { ret = EFI_OUT_OF_RESOURCES; goto error; } ... If malloc() fails, we should call efi_initrd_deregister() within try_load_entry(). Should I submit a patch? -Takahiro Akashi > Signed-off-by: Heinrich Schuchardt > --- > lib/efi_loader/efi_load_initrd.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/efi_loader/efi_load_initrd.c b/lib/efi_loader/efi_load_initrd.c > index c5e6652e66..3d6044f760 100644 > --- a/lib/efi_loader/efi_load_initrd.c > +++ b/lib/efi_loader/efi_load_initrd.c > @@ -230,6 +230,9 @@ efi_status_t efi_initrd_register(void) > */ > void efi_initrd_deregister(void) > { > + if (!efi_initrd_handle) > + return; > + > efi_delete_handle(efi_initrd_handle); > efi_initrd_handle = NULL; > } > -- > 2.37.2 >