]> git.karo-electronics.de Git - karo-tx-linux.git/commit
kdump: crashk_res init check for /sys/kernel/kexec_crash_size
authorMichael Holzheu <holzheu@linux.vnet.ibm.com>
Fri, 16 Dec 2011 04:50:45 +0000 (15:50 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 19 Dec 2011 07:19:55 +0000 (18:19 +1100)
commit6fac3ac71a89e7f0b31df20f3ee22f759f1b2542
treef4bbe7c408c920e9a563e29db6398decafe1c5b7
parent33a7085b8f9799a4d36a8869baa4e5e9ec2958f9
kdump: crashk_res init check for /sys/kernel/kexec_crash_size

Currently it is possible to set the crash_size via the sysfs
/sys/kernel/kexec_crash_size even if no crash kernel memory has been
defined with the "crashkernel" parameter.  In this case "crashk_res" is
not initialized and crashk_res.start = crashk_res.end = 0.  Unfortunately
resource_size(&crashk_res) returns 1 in this case.  This breaks the s390
implementation of crash_(un)map_reserved_pages().

To fix the problem the correct "old_size" is now calculated in
crash_shrink_memory().  "old_size is set to "0" if crashk_res is not
initialized.  With this change crash_shrink_memory() will do nothing, when
"crashk_res" is not initialized.  It will return "0" for "echo 0 >
/sys/kernel/kexec_crash_size" and -EINVAL for "echo [not zero] >
/sys/kernel/kexec_crash_size".

In addition to that this patch also simplifies the "ret = -EINVAL" vs.
"ret = 0" logic as suggested by Simon Horman.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Dave Young <dyoung@redhat.com>
Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/kexec.c