Merge tag 'kvm-s390-master-20150303' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / kernel / kexec.c
index 35dcac4b5c1c23474e423de65949c38c5d2805d8..38c25b1f2fd5c7e4922f36cf884519c1bd485a85 100644 (file)
@@ -444,7 +444,7 @@ arch_kexec_apply_relocations(const Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
 }
 
 /*
- * Free up memory used by kernel, initrd, and comand line. This is temporary
+ * Free up memory used by kernel, initrd, and command line. This is temporary
  * memory allocation which is not needed any more after these buffers have
  * been loaded into separate segments and have been copied elsewhere.
  */
@@ -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;