OSDN Git Service

pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places
[uclinux-h8/linux.git] / kernel / kexec.c
index c852776..38c25b1 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.
  */
@@ -856,8 +856,6 @@ static int kimage_set_destination(struct kimage *image,
 
        destination &= PAGE_MASK;
        result = kimage_add_entry(image, destination | IND_DESTINATION);
-       if (result == 0)
-               image->destination = destination;
 
        return result;
 }
@@ -869,8 +867,6 @@ static int kimage_add_page(struct kimage *image, unsigned long page)
 
        page &= PAGE_MASK;
        result = kimage_add_entry(image, page | IND_SOURCE);
-       if (result == 0)
-               image->destination += PAGE_SIZE;
 
        return result;
 }
@@ -1288,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;