Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[cascardo/linux.git] / kernel / kexec_file.c
index c72d2ff..037c321 100644 (file)
@@ -274,8 +274,11 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,
                return -EBUSY;
 
        dest_image = &kexec_image;
-       if (flags & KEXEC_FILE_ON_CRASH)
+       if (flags & KEXEC_FILE_ON_CRASH) {
                dest_image = &kexec_crash_image;
+               if (kexec_crash_image)
+                       arch_kexec_unprotect_crashkres();
+       }
 
        if (flags & KEXEC_FILE_UNLOAD)
                goto exchange;
@@ -324,6 +327,9 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,
 exchange:
        image = xchg(dest_image, image);
 out:
+       if ((flags & KEXEC_FILE_ON_CRASH) && kexec_crash_image)
+               arch_kexec_protect_crashkres();
+
        mutex_unlock(&kexec_mutex);
        kimage_free(image);
        return ret;
@@ -881,7 +887,10 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min,
        return 0;
 out:
        vfree(pi->sechdrs);
+       pi->sechdrs = NULL;
+
        vfree(pi->purgatory_buf);
+       pi->purgatory_buf = NULL;
        return ret;
 }