Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp369927ybj; Wed, 6 May 2020 20:23:05 -0700 (PDT) X-Google-Smtp-Source: APiQypLTsfFNlfyuMUKvAjjZ/atqpRJs4xRXBPzvgmgiF8PBAF2AjrPGQGM8hjUcEXS31VB1nETv X-Received: by 2002:a17:906:1804:: with SMTP id v4mr10534089eje.104.1588821784907; Wed, 06 May 2020 20:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588821784; cv=none; d=google.com; s=arc-20160816; b=RHzbmDG8hScx3nsxt/I2nIq9ThUFXR23UN7ODQBhAlMk8DIIcZjlCewvx6YZMXFTX4 X/93ZBXS8EEWuNXEF5HvJuqx4ZlkeM6MA4ZzmDkD+KiaPEeallgvDCCl+eI/scCDcxQi 7FxpjSc2eQMHnA6EEouQkNd7FKf8PjqQBnSsVEFWECfPvgJX79wGZqaio294otmXaJEA tUDdjR1UdcKrFk+K+wttAJXRxX10htNGSVpYlkgCOnpdV/KAQ695luWrMfNQV78Nbs/t trcgIWQEUn9XPJr/2vxnzZPJOFVN3SK+QcsjZLcRUTPHVXc+TX7hI/GwbUavkFgUOTJ2 s8PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=TK5/TPkCA1YNIr46wnEPWN0J5TK8aDr7sImaoLSYw5c=; b=ArJ7kUBeacRiM8SLc1KC92MRqCYJjfb+/WikS2ydLgoih1RpnOo/Pg5wAqMDxqIrAJ FMTK3b8wbZE4yJWfmMomYD+PhhRVaLnscfshnAbDH315jo60sqJkiQKhboQHQycP3KfM 2nHUZNSUr1W81gB7UGoXRTfnA6Owzz1Eo7hJVaTRhcmZ7FNEZqTUDMkJIlw7BdMTkSM8 brJJ9nUsbbapR0tLtUwLK82CrxIB10HKWrI2LvTy73izL+FG6J/DkDhozO+7N1kRYsDx f59m8bkyfojIs2E+wXcprNYQeAc37hEzgz7BY4f2gh4XtIkiMeP6zaUyg/WL2f1Emlp/ VDyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fECPcz9f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si2658932ejl.134.2020.05.06.20.22.42; Wed, 06 May 2020 20:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fECPcz9f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbgEGBtW (ORCPT + 99 others); Wed, 6 May 2020 21:49:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39617 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725826AbgEGBtW (ORCPT ); Wed, 6 May 2020 21:49:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588816160; 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=TK5/TPkCA1YNIr46wnEPWN0J5TK8aDr7sImaoLSYw5c=; b=fECPcz9fhmekTNETwLqqym4u6xoPxeVaytJdJtjMywQoboCG2k8L1erjdZG3QhwOV5mpxw KwR8/BpvA1oyeCFAsKTQ9StWmO8UpoqBeIcxTgh+6RnUp3VpAGeS7lpgqF38HMw1mtmuWP vkRmE3B+OBgPAXGmj7EvhEv58YVH+2o= 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-329-GDF1pxX9MseiT_uydVw24A-1; Wed, 06 May 2020 21:49:18 -0400 X-MC-Unique: GDF1pxX9MseiT_uydVw24A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DC67107ACCA; Thu, 7 May 2020 01:49:17 +0000 (UTC) Received: from [10.10.64.2] (ovpn-64-2.rdu2.redhat.com [10.10.64.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0071310246E7; Thu, 7 May 2020 01:49:15 +0000 (UTC) Subject: Re: [PATCH] efi/libstub/x86: Free EFI map buffer in allocate_e820() To: Ard Biesheuvel Cc: eric.snowberg@oracle.com, Ingo Molnar , Arvind Sankar , Thomas Gleixner , linux-efi , Linux Kernel Mailing List References: <20200505190016.4350-1-lszubowi@redhat.com> From: Lenny Szubowicz Message-ID: Date: Wed, 6 May 2020 21:49:15 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/6/20 3:23 AM, Ard Biesheuvel wrote: > On Tue, 5 May 2020 at 21:00, Lenny Szubowicz wrote: >> >> In allocate_e820(), free the EFI map buffer that has been returned >> by efi_get_memory_map(). The returned size of the EFI map buffer >> is used to allocate an adequately sized e820ext buffer, if it's >> needed. But the contents of that EFI map buffer is not used at all >> and the local pointer to it is gone on return from allocate_e820(). >> >> Signed-off-by: Lenny Szubowicz >> --- >> drivers/firmware/efi/libstub/x86-stub.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c >> index 05ccb229fb45..4efe3e7a218d 100644 >> --- a/drivers/firmware/efi/libstub/x86-stub.c >> +++ b/drivers/firmware/efi/libstub/x86-stub.c >> @@ -623,6 +623,9 @@ static efi_status_t allocate_e820(struct boot_params *params, >> if (status != EFI_SUCCESS) >> return status; >> >> + /* Allocated EFI map buf is not used here. Just need its size. */ >> + efi_bs_call(free_pool, map); >> + > > Wouldn't it be better to call BS->GetMemoryMap() directly here, with a > zero size for the input buffer? I agree, that's a good suggestion. V2 coming shortly after testing. > >> nr_desc = buff_size / desc_size; >> >> if (nr_desc > ARRAY_SIZE(params->e820_table)) { >> -- >> 2.18.4 >> >