Skip to content

Commit

Permalink
kexec: fix Oops in crash_shrink_memory()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: WANG Cong <[email protected]>
Cc: Simon Horman <[email protected]>
Cc: Vivek Goyal <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Pavan Naregundi authored and torvalds committed Jun 29, 2010
1 parent 482ce51 commit e05bd33
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kernel/kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit e05bd33

Please sign in to comment.