Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1801322ybn; Thu, 26 Sep 2019 02:24:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqygHScf8MtTk2D4IYwQLHP21tz18S8bVdDPcgXzG61a5qtotImMt7f6wqljDXp49QHJaEEH X-Received: by 2002:a50:9a05:: with SMTP id o5mr2490181edb.44.1569489845654; Thu, 26 Sep 2019 02:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569489845; cv=none; d=google.com; s=arc-20160816; b=nhFHTj3pzmMLxq4R+6rSj5n/wXe09Nn4VruPb09zNewDAeIxaB8149V1mOg6w6nxY/ XW9ZFOVMry0yY5tQRQ17+4/r4JA5SiEZnTX66OyHFwVNKLOoLVswKCjLJEdA5nrcLRV2 CBpp8+0tlFWuuKVVNTu36Uh6i8f9WnJmsUI/KO5eiMTRt9Ss0frRhXyTcySV4jsnUAfV 4zcnzlU2ejT9kQV9DtWfZqqZtuCXXALnREMyaJjzmBYnmH5l0T2KQlZQF2s25iew2i/J LVQv/BaI+W4wU+LUnGh2tfHxdm8YERC6eHJMl5yCWxUPG8tt8k2c5MVIdKE5aoJI2CRg bPUw== 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:references:cc:to:from:subject; bh=ciZJPpOydXnYxqFrRLKDm+awQO64TZNxKoDFD8JSIMs=; b=plEGyUPUL/CIPgRhzgvSZfGK0GWKfBVjKMApiDusV3b1Q/IJ5KDjC6mXaEXztnN0Tu q6tuHrnjTwWKw4RLRuVgHtjYMmYq324RmSUdSrKhH8R0m9TKkYNKd5dzCIL9HPXiiY1X PLfTPHMg93PswbtKaH8DSQa/LRI51tMmcQstZC8X/F0SUnfL67T01ho+t5TnqIy995Er Y7pfnfdvSBnUAo9ndV/H3b97ymvYNPbUXvZAzXlUzHUHTak0nGaEMosSBP0oTaEWP++R Pdf24ncPT0pkCYTCG67ndeMWiK2r84+gof5bp7qoU68SY7n+8fr+Yax04SbxbY+no72g dyGg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si935362edm.271.2019.09.26.02.23.42; Thu, 26 Sep 2019 02:24:05 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727536AbfIYJU4 (ORCPT + 99 others); Wed, 25 Sep 2019 05:20:56 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:53956 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727387AbfIYJUW (ORCPT ); Wed, 25 Sep 2019 05:20:22 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 4C68EDA07C1C298F7F10; Wed, 25 Sep 2019 17:20:20 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Wed, 25 Sep 2019 17:20:17 +0800 Subject: [PATCH 2/2] x86/efi: Fix memory leak for EFI memmap reservations From: Yunfeng Ye To: "ard.biesheuvel@linaro.org" , , , "tglx@linutronix.de" , , , , CC: , , "linux-kernel@vger.kernel.org" References: <775bcf46-0f4e-a1a9-5a40-05f833cd7a1a@huawei.com> Message-ID: <26d637af-480b-e874-ee84-9b2abe43630b@huawei.com> Date: Wed, 25 Sep 2019 17:20:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <775bcf46-0f4e-a1a9-5a40-05f833cd7a1a@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are some memory leaks in failure path after efi_memmap_alloc(). add efi_memmap_free() for this situation. Fixes: 816e76129ed5 ("efi: Allow drivers to reserve boot services forever") Signed-off-by: Yunfeng Ye --- arch/x86/platform/efi/quirks.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 3b9fd67..a755f35 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -285,6 +285,7 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size) new = early_memremap(new_phys, new_size); if (!new) { + efi_memmap_free(new_phys, num_entries); pr_err("Failed to map new boot services memmap\n"); return; } @@ -470,6 +471,7 @@ void __init efi_free_boot_services(void) new = memremap(new_phys, new_size, MEMREMAP_WB); if (!new) { + efi_memmap_free(new_phys, num_entries); pr_err("Failed to map new EFI memmap\n"); return; } @@ -493,6 +495,7 @@ void __init efi_free_boot_services(void) memunmap(new); if (efi_memmap_install(new_phys, num_entries)) { + efi_memmap_free(new_phys, num_entries); pr_err("Could not install new EFI memmap\n"); return; } -- 1.8.3.1