Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752443AbcCAICj (ORCPT ); Tue, 1 Mar 2016 03:02:39 -0500 Received: from mail-pa0-f67.google.com ([209.85.220.67]:33071 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbcCAICg (ORCPT ); Tue, 1 Mar 2016 03:02:36 -0500 From: Minfei Huang To: ebiederm@xmission.com, akpm@linux-foundation.org Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, mhuang@redhat.com, Minfei Huang Subject: [PATCH V2 1/2] kexec: Make a pair of map/unmap reserved pages in error path Date: Tue, 1 Mar 2016 16:02:28 +0800 Message-Id: <1456819349-8650-2-git-send-email-mnfhuang@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456819349-8650-1-git-send-email-mnfhuang@gmail.com> References: <1456819349-8650-1-git-send-email-mnfhuang@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1542 Lines: 55 For some arch, kexec shall map the reserved pages, then use them, when we try to start the kdump service. kexec may return directly, without unmaping the reserved pages, if it fails during starting service. To fix it, we make a pair of map/unmap reserved pages both in generic path and error path. Signed-off-by: Minfei Huang --- kernel/kexec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/kexec.c b/kernel/kexec.c index ee70aef..5cd60c4 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -169,6 +169,7 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, dest_image = &kexec_image; if (flags & KEXEC_ON_CRASH) dest_image = &kexec_crash_image; + if (nr_segments > 0) { unsigned long i; @@ -190,22 +191,25 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, segments, flags); } if (result) - goto out; + goto unmap_page; if (flags & KEXEC_PRESERVE_CONTEXT) image->preserve_context = 1; result = machine_kexec_prepare(image); if (result) - goto out; + goto unmap_page; for (i = 0; i < nr_segments; i++) { result = kimage_load_segment(image, &image->segment[i]); if (result) - goto out; + goto unmap_page; } kimage_terminate(image); +unmap_page: if (flags & KEXEC_ON_CRASH) crash_unmap_reserved_pages(); + if (result) + goto out; } /* Install the new kernel, and Uninstall the old */ image = xchg(dest_image, image); -- 1.9.1