Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4593072imm; Mon, 25 Jun 2018 19:42:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZ2JgnL0npfg2YnTrKZqPvLVBJbufSYNiEqRPPBUHCFOFSYQneUT+MnyyPxfCCmV5tw9Xb X-Received: by 2002:a62:bd03:: with SMTP id a3-v6mr15304726pff.138.1529980946029; Mon, 25 Jun 2018 19:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529980946; cv=none; d=google.com; s=arc-20160816; b=k+2cXdpJUCt6cs+N4czTVJuv2QCf+t8IBTkaHim8+lcg71rGuD8bmzaFM4LlePtNTp dzBnW15OY/bXoq4vsQDrR0hfwPvt9FXP7O4OR4z9RbF/nBwj2MdfpvexPs4ZDq77NSvp 8dIoRiUFHtggqEZLyb2mx1xyRQv2utCAhgAjtWURwcTdqDUeXO4mMWiVxsV2tuTEBFxr 2vUtsj5AVY8AatGVloNy/Pk8mfaguUtFyYA7ckkinYNbV52jqk7+3U/n6UzhuNz3U+gr 23N0q4EpjBA4wWdWiPjbmezui4Gfvp7y9l/qZj58vd8ryhHbHRBAktSuYeDU/PyDvsZf /eeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=5kVb/6qYZ7n5OrVzt8edMUGNDrLY4wz94PhXnsQIG8s=; b=p7pVAUGT5NhBuFqws8ZtGPIPar5qFQJVW+5us/HEtrBLz95lfKG87/RUEjn0DYxn4C gTpOyD3mAlWW7v64c68okFL+bVa9x9qjOg3wCSRFgb2ggBefc169fyaEpvvB2OSNO50L QkuKLqD5nQAJdvrzOfhRYJpdVIItzBk6Y6ve9u0xzC9BHtslCM4HR/o6Rzc3CcYkI1Oj 8uLqSiNOyGDlbHFrlgQfFCnT82zRWrcpS9hu3XJmbx+GZM4yrt+1rZEe3hHPSklMFRKN ckFsdndMarhW4ScJB7fZuDsUOkOfVQwv7aNoZIOHNzOw0c2sAbJ9Yay3L1IzKfUsHZ6c o7DQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10-v6si513656plg.396.2018.06.25.19.42.11; Mon, 25 Jun 2018 19:42:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755852AbeFZCle (ORCPT + 99 others); Mon, 25 Jun 2018 22:41:34 -0400 Received: from mga06.intel.com ([134.134.136.31]:31481 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754175AbeFZClc (ORCPT ); Mon, 25 Jun 2018 22:41:32 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2018 19:41:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,272,1526367600"; d="scan'208";a="51891100" Received: from sai-dev-mach.sc.intel.com ([143.183.140.145]) by orsmga007.jf.intel.com with ESMTP; 25 Jun 2018 19:41:31 -0700 From: Sai Praneeth Prakhya To: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sai Praneeth , Lee Chun-Yi , Borislav Petkov , Dave Young , Laszlo Ersek , Bhupesh Sharma , Ricardo Neri , Ravi Shankar , Matt Fleming , Ard Biesheuvel Subject: [PATCH] efi: Free existing memory map before installing new memory map Date: Mon, 25 Jun 2018 19:41:32 -0700 Message-Id: <1529980892-11833-1-git-send-email-sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sai Praneeth efi_memmap_install(), unmaps the existing memory map and installs the new memory map but doesn't free the memory allocated to the existing memory map. Fortunately, the details about the existing memory map are stored in efi.memmap. Hence, use them to free the memory. Signed-off-by: Sai Praneeth Prakhya Reported-by: Ard Biesheuvel Cc: Lee Chun-Yi Cc: Borislav Petkov Cc: Dave Young Cc: Laszlo Ersek Cc: Bhupesh Sharma Cc: Ricardo Neri Cc: Ravi Shankar Cc: Matt Fleming Cc: Ard Biesheuvel --- Note: Patch based on efi tree @https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git drivers/firmware/efi/memmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c index 678e85704054..68b27b14fe94 100644 --- a/drivers/firmware/efi/memmap.c +++ b/drivers/firmware/efi/memmap.c @@ -229,6 +229,9 @@ int __init efi_memmap_install(phys_addr_t addr, unsigned int nr_map) efi_memmap_unmap(); + /* Free the memory allocated to the existing memory map */ + efi_memmap_free(efi.memmap.phys_map, efi.memmap.nr_map, efi.memmap.late); + data.phys_map = addr; data.size = efi.memmap.desc_size * nr_map; data.desc_version = efi.memmap.desc_version; -- 2.7.4