Skip to content

Commit

Permalink
kexec: simplify conditional
Browse files Browse the repository at this point in the history
Simplify the code around one of the conditionals in the kexec_load syscall
routine.

The original code was confusing with a redundant check on KEXEC_ON_CRASH
and comments outside of the conditional block.  This change switches the
order of the conditional check, and cleans up the comments for the
conditional.  There is no functional change to the code.

Signed-off-by: Geoff Levand <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Maximilian Attems <[email protected]>
Cc: Michal Marek <[email protected]>
Cc: Paul Bolle <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
glevand authored and torvalds committed Feb 17, 2015
1 parent 9dc5c05 commit 518a0c7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions kernel/kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,19 +1284,22 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
if (nr_segments > 0) {
unsigned long i;

/* Loading another kernel to reboot into */
if ((flags & KEXEC_ON_CRASH) == 0)
result = kimage_alloc_init(&image, entry, nr_segments,
segments, flags);
/* Loading another kernel to switch to if this one crashes */
else if (flags & KEXEC_ON_CRASH) {
/* Free any current crash dump kernel before
if (flags & KEXEC_ON_CRASH) {
/*
* Loading another kernel to switch to if this one
* crashes. Free any current crash dump kernel before
* we corrupt it.
*/

kimage_free(xchg(&kexec_crash_image, NULL));
result = kimage_alloc_init(&image, entry, nr_segments,
segments, flags);
crash_map_reserved_pages();
} else {
/* Loading another kernel to reboot into. */

result = kimage_alloc_init(&image, entry, nr_segments,
segments, flags);
}
if (result)
goto out;
Expand Down

0 comments on commit 518a0c7

Please sign in to comment.