aboutsummaryrefslogtreecommitdiff
path: root/kernel/kexec.c
diff options
context:
space:
mode:
authorPavan Naregundi <pavan@linux.vnet.ibm.com>2010-06-29 15:05:28 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-06-29 15:29:31 -0700
commite05bd3367bd3d88715b53766f95bb3a8ec7ab59e (patch)
treedb9f13cd687c39bf873ff5dbed28bbd142fc6940 /kernel/kexec.c
parent482ce512c543f3b30ab881702fa997e71252e604 (diff)
downloadlinux-2.6.34-ux500-e05bd3367bd3d88715b53766f95bb3a8ec7ab59e.tar.gz
kexec: fix Oops in crash_shrink_memory()
When crashkernel is not enabled, "echo 0 > /sys/kernel/kexec_crash_size" OOPSes the kernel in crash_shrink_memory. This happens when crash_shrink_memory tries to release the 'crashk_res' resource which are not reserved. Also value of "/sys/kernel/kexec_crash_size" shows as 1, which should be 0. This patch fixes the OOPS in crash_shrink_memory and shows "/sys/kernel/kexec_crash_size" as 0 when crash kernel memory is not reserved. Signed-off-by: Pavan Naregundi <pavan@linux.vnet.ibm.com> Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com> Cc: Simon Horman <horms@verge.net.au> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/kexec.c')
-rw-r--r--kernel/kexec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 474a84715ea..131b1703936 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1089,9 +1089,10 @@ void crash_kexec(struct pt_regs *regs)
size_t crash_get_memory_size(void)
{
- size_t size;
+ size_t size = 0;
mutex_lock(&kexec_mutex);
- size = crashk_res.end - crashk_res.start + 1;
+ if (crashk_res.end != crashk_res.start)
+ size = crashk_res.end - crashk_res.start + 1;
mutex_unlock(&kexec_mutex);
return size;
}
@@ -1134,7 +1135,7 @@ int crash_shrink_memory(unsigned long new_size)
free_reserved_phys_range(end, crashk_res.end);
- if (start == end)
+ if ((start == end) && (crashk_res.parent != NULL))
release_resource(&crashk_res);
crashk_res.end = end - 1;