Skip to content

Commit b67152e

Browse files
Minfei HuangAlex Shi
authored andcommitted
kexec: make a pair of map/unmap reserved pages in error path
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. This patch only affects s390. Other architecturess don't implement the interface of crash_unmap_reserved_pages and crash_map_reserved_pages. It isn't a urgent patch. Kernel can work well without any risk, although the reserved pages are not unmapped before returning in error path. Signed-off-by: Minfei Huang <mnfhuang@gmail.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Xunlei Pang <xlpang@redhat.com> Cc: Baoquan He <bhe@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit 917a35605f09c0d16aeb2e92c7fbff562e19a116) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent cb24e1e commit b67152e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

kernel/kexec.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,25 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
194194
segments, flags);
195195
}
196196
if (result)
197-
goto out;
197+
goto unmap_page;
198198

199199
if (flags & KEXEC_PRESERVE_CONTEXT)
200200
image->preserve_context = 1;
201201
result = machine_kexec_prepare(image);
202202
if (result)
203-
goto out;
203+
goto unmap_page;
204204

205205
for (i = 0; i < nr_segments; i++) {
206206
result = kimage_load_segment(image, &image->segment[i]);
207207
if (result)
208-
goto out;
208+
goto unmap_page;
209209
}
210210
kimage_terminate(image);
211+
unmap_page:
211212
if (flags & KEXEC_ON_CRASH)
212213
crash_unmap_reserved_pages();
214+
if (result)
215+
goto out;
213216
}
214217
/* Install the new kernel, and Uninstall the old */
215218
image = xchg(dest_image, image);

0 commit comments

Comments
 (0)