From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.5734.1624958884464470079 for ; Tue, 29 Jun 2021 02:28:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Je7qC9Lm; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624958883; 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=ERrdnDhlusBpqtMSotBtopTf5hG7zQTPliILqThG6Ec=; b=Je7qC9Lm8BOFdDLwEIAgzkKrbIwm4giIWidozPyGZRR+HWuRjrSgHt3E1AgzVW8RjajYhW WAwTMy5NMCgef2rAGUFgaQnWxOWqkQnp5TK9/0BfWj3NErakqfiVg8YW74itROPfIENkUS lGlT0/jz7+szUsbs9mbJgVQZrXOWCII= 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-165-kWbESqflO2KyMSwuv4keQA-1; Tue, 29 Jun 2021 05:28:01 -0400 X-MC-Unique: kWbESqflO2KyMSwuv4keQA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3C2D1084F53; Tue, 29 Jun 2021 09:27:59 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-158.ams2.redhat.com [10.36.114.158]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B49A60854; Tue, 29 Jun 2021 09:27:58 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v3 1/5] OvmfPkg/GenericQemuLoadImageLib: plug cmdline blob leak on success To: devel@edk2.groups.io, dovmurik@linux.ibm.com Cc: Ard Biesheuvel , Jordan Justen , James Bottomley , Tobin Feldman-Fitzthum References: <20210628105110.379951-1-dovmurik@linux.ibm.com> <20210628105110.379951-2-dovmurik@linux.ibm.com> From: "Laszlo Ersek" Message-ID: Date: Tue, 29 Jun 2021 11:27:56 +0200 MIME-Version: 1.0 In-Reply-To: <20210628105110.379951-2-dovmurik@linux.ibm.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 06/28/21 12:51, Dov Murik wrote: > When QemuLoadKernelImage() ends successfully, the command-line blob is > not freed, even though it is not used elsewhere (its content is already > copied to KernelLoadedImage->LoadOptions). The memory leak bug was > introduced in commit ddd2be6b0026 ("OvmfPkg: provide a generic > implementation of QemuLoadImageLib", 2020-03-05). > > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: James Bottomley > Cc: Tobin Feldman-Fitzthum > Reported-by: Laszlo Ersek > Fixes: ddd2be6b0026abcd0f819b3915fc80c3de81dd62 > Signed-off-by: Dov Murik > --- > OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c > index 114db7e8441f..8a29976ae172 100644 > --- a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c > +++ b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c > @@ -193,14 +193,16 @@ QemuLoadKernelImage ( > } > > *ImageHandle = KernelImageHandle; > - return EFI_SUCCESS; > + Status = EFI_SUCCESS; > > FreeCommandLine: > if (CommandLineSize > 0) { > FreePool (CommandLine); > } > UnloadImage: > - gBS->UnloadImage (KernelImageHandle); > + if (EFI_ERROR (Status)) { > + gBS->UnloadImage (KernelImageHandle); > + } > > return Status; > } > Reviewed-by: Laszlo Ersek