public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] Fix memory access errors for kexec PPC
@ 2011-04-20  9:32 Suzuki Poulose
  2011-04-27  6:17 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Suzuki Poulose @ 2011-04-20  9:32 UTC (permalink / raw)
  To: kexec@lists.infradead.org; +Cc: horms

Hi,

I was trying the kexec for ppc32 and came across a couple of memory errors
while running with glibc.

The attached patch is the outcome of the glibc's alerts !
We define buf[MAXBYTES-1] and issue  fread(buf, 1, MAXBYTES, file), which glibc
reports an error.

Also there is a typo in the realloc_memory_ranges() code for ppc which causes in
a double free().

Kindly apply.


Thanks
Suzuki


---

Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>

diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c
index 7bfad20..7853dbe 100644
--- a/kexec/arch/ppc/crashdump-powerpc.c
+++ b/kexec/arch/ppc/crashdump-powerpc.c
@@ -83,7 +83,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
  	int memory_ranges = 0;
  	char device_tree[256] = "/proc/device-tree/";
  	char fname[256];
-	char buf[MAXBYTES-1];
+	char buf[MAXBYTES];
  	DIR *dir, *dmem;
  	FILE *file;
  	struct dirent *dentry, *mentry;
diff --git a/kexec/arch/ppc/kexec-ppc.c b/kexec/arch/ppc/kexec-ppc.c
index ab76d6f..837021f 100644
--- a/kexec/arch/ppc/kexec-ppc.c
+++ b/kexec/arch/ppc/kexec-ppc.c
@@ -196,7 +196,7 @@ static int realloc_memory_ranges(void)
  	if (!memory_range)
  		goto err;
  
-	base_memory_range = (struct memory_range *) realloc(memory_range,
+	base_memory_range = (struct memory_range *) realloc(base_memory_range,
  			memory_range_len);
  	if (!base_memory_range)
  		goto err;
@@ -319,7 +319,7 @@ static int get_devtree_details(unsigned long kexec_flags)
  	unsigned long long htab_base, htab_size;
  	unsigned long long kernel_end;
  	unsigned long long initrd_start, initrd_end;
-	char buf[MAXBYTES-1];
+	char buf[MAXBYTES];
  	char device_tree[256] = "/proc/device-tree/";
  	char fname[256];
  	DIR *dir, *cdir;

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-27  7:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-20  9:32 [PATCH] Fix memory access errors for kexec PPC Suzuki Poulose
2011-04-27  6:17 ` Simon Horman
2011-04-27  6:40   ` Suzuki Poulose
2011-04-27  7:48     ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox