Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1557883ybj; Wed, 6 May 2020 00:29:22 -0700 (PDT) X-Google-Smtp-Source: APiQypIWxL99YoClpQkEAaSSlLetymZoNuzI+q+N2X1OK/sKtYZgsX6hJK096HjQprMIwgfWsJbn X-Received: by 2002:a17:906:3713:: with SMTP id d19mr5896068ejc.111.1588750162466; Wed, 06 May 2020 00:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588750162; cv=none; d=google.com; s=arc-20160816; b=DUI2HY14t4ohAKP//7il+aqHr8nSGkX1cXxg/mPfXR+0rHremq3Kgz6A8P73yLVrs7 fVer1vlDfmhLidTCspxw1pGrZw1EHQWXxBXq2ZUqdOZsbAnIJ+0dBKeD6AcaeZMO7AVp aNgqoEIomWC2cnKAPXfiICMdd+x5mU94UOmRIWMIwiH2JGWUPplZJzd5o1E0sqyU8eDf E38LYX+JXU6L5B9v0ZohNr5IpFgexbz9TqcBuQpzaX3xggfqXvZSEZIQ3e2AKHPYYBdi TXZC8gKQ1sct9VeeWbe5svd5iSJ7agwHIz1yE/jvBtmo98LItgH8zsw77YtyWWddmF3S fNpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8SMczvpT0/Us/2VFiiZ/+lkujaTSWhGHEC6fKgRlr7k=; b=wkkMErayCFs0tkc3gxw49/YchjQHQ3WgePUco13x8YUF+VzNFeVycCZtfck0LODMP8 1m+JESrp6iKxJ3WzeMlc+lHG086V3qL9QfEk/G9o6bTE6A9OkVkaqg6xly6SQ+bNHD9Z 6pFld3J+v/4kMewvuAijftDf0j+HOWczMUnu+17VjsqFV6HO993+UPswtn5B5TCMnzgd AARMObzKkD125ZXdnl89lYBYkuwgDZydQPoV2fEGFKWcSB751fqrEEvBrQ/xDQnWP/qD mWM0Q7o6KS7JbzvOiY03RHDg2cvcap/1h5YhUNUcIpkrjPsB/pruXhNACAYnnbBBJd2i URBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="2dF/3JTT"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n21si677075ejc.113.2020.05.06.00.29.00; Wed, 06 May 2020 00:29:22 -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=@kernel.org header.s=default header.b="2dF/3JTT"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728351AbgEFHYI (ORCPT + 99 others); Wed, 6 May 2020 03:24:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:33324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbgEFHYH (ORCPT ); Wed, 6 May 2020 03:24:07 -0400 Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1542E2075A; Wed, 6 May 2020 07:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588749847; bh=x7OyI4ujQqJw0j0GzC4hS3Aq2xvKqYQlLnWoJNviDjI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=2dF/3JTTgUTXkPe00eAGP+i/UrEb6At13z6L8h0yfrl/xzNk2Y5LE5dG3bFPy3gsV PanOXrzYPZqsVHdv4gTC1p54m9U/IrzFxdW0PPJ6mB4mrKWoHAmCzVMzr1tCUx8MbD mgM6oToSjO1sRXefqDLWUFwvnbNkWAeT0wdLMaio= Received: by mail-io1-f43.google.com with SMTP id k18so1201848ion.0; Wed, 06 May 2020 00:24:07 -0700 (PDT) X-Gm-Message-State: AGi0PuYoT4ZZstg3sPL6oQwiLuTiKNjIDIeCqxshoR6lAX/ZSnl3ww0A /Pdf8tA7K/oPGQ8sXyaiAIwRFquy7Pnog8qw7fg= X-Received: by 2002:a02:8247:: with SMTP id q7mr6901558jag.68.1588749846416; Wed, 06 May 2020 00:24:06 -0700 (PDT) MIME-Version: 1.0 References: <20200505190016.4350-1-lszubowi@redhat.com> In-Reply-To: <20200505190016.4350-1-lszubowi@redhat.com> From: Ard Biesheuvel Date: Wed, 6 May 2020 09:23:55 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] efi/libstub/x86: Free EFI map buffer in allocate_e820() To: Lenny Szubowicz Cc: eric.snowberg@oracle.com, Ingo Molnar , Arvind Sankar , Thomas Gleixner , linux-efi , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > nr_desc = buff_size / desc_size; > > if (nr_desc > ARRAY_SIZE(params->e820_table)) { > -- > 2.18.4 >