]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - kernel/kexec_core.c
kexec: fix a memory leak in crash_shrink_memory()
[thirdparty/linux.git] / kernel / kexec_core.c
index 3d578c6fefee385527a4fded25d50826f322dbdb..22acee18195a5919da0b4e27c461a25440808b39 100644 (file)
@@ -1122,6 +1122,7 @@ int crash_shrink_memory(unsigned long new_size)
        start = crashk_res.start;
        end = crashk_res.end;
        old_size = (end == 0) ? 0 : end - start + 1;
+       new_size = roundup(new_size, KEXEC_CRASH_MEM_ALIGN);
        if (new_size >= old_size) {
                ret = (new_size == old_size) ? 0 : -EINVAL;
                goto unlock;
@@ -1133,9 +1134,7 @@ int crash_shrink_memory(unsigned long new_size)
                goto unlock;
        }
 
-       start = roundup(start, KEXEC_CRASH_MEM_ALIGN);
-       end = roundup(start + new_size, KEXEC_CRASH_MEM_ALIGN);
-
+       end = start + new_size;
        crash_free_reserved_phys_range(end, crashk_res.end);
 
        if ((start == end) && (crashk_res.parent != NULL))