On Thu, 2010-06-10 at 14:26 -0700, Andrew Morton wrote:
> On Wed, 09 Jun 2010 11:57:14 +0530
> Pavan Naregundi <[email protected]> wrote:
> 
> > Resending the patch with fixed style issues.
> > 
> > Signed-off-by: Pavan Naregundi <[email protected]>
> > Reviewed-by: WANG Cong <[email protected]>
> > --
> > 
> > 
> > 
> > 
> > [fix-kexec.patch  text/x-patch (685B)]
> > diff -Naur a/kernel/kexec.c b/kernel/kexec.c
> > --- a/kernel/kexec.c        2010-06-08 21:17:21.850000033 +0530
> > +++ b/kernel/kexec.c        2010-06-09 18:01:37.590007921 +0530
> > @@ -1089,9 +1089,10 @@
> >  
> >  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 @@
> >  
> >     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;
> 
> The patch doesn't have a changelog and I'd prefer not to have to crawl
> through the email thread and write one myself.
> 
> Please resend, including a full description of the bug and of its fix.

Subject: kexec: fix Oops in crash_shrink_memory()
From: Pavan Naregundi <[email protected]>

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]>
---

diff -uprN a/kernel/kexec.c b/kernel/kexec.c
--- a/kernel/kexec.c	2010-06-08 21:17:21.850000033 +0530
+++ b/kernel/kexec.c	2010-06-09 18:01:37.590007921 +0530
@@ -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 ne
 
 	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;
 
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to