public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* kernel oops due to aligment error in cmdlinepart.c
@ 2003-08-01  0:02 George G. Davis
  2003-08-01 13:24 ` David Woodhouse
  0 siblings, 1 reply; 2+ messages in thread
From: George G. Davis @ 2003-08-01  0:02 UTC (permalink / raw)
  To: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 417 bytes --]

Greetings,

I've been using the latest MTD CVS (+/- a few days) on an ARM Integrator/CM920T
running linux-2.4.20'ish and have found that cmdlinepart.c has a struct alignment
problem which causes a kernel oops. The attached patch fixes the alignment problem
for me (YMMV : ). I've successfully tested this on an ARM Integrator/CM920T, ADS
Graphics Client Plus and TI Innovator/OMAP1510, FWIW. : )

--
Regards,
George


[-- Attachment #2: cmdlinepart.patch --]
[-- Type: text/plain, Size: 1228 bytes --]

Index: drivers/mtd/cmdlinepart.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/cmdlinepart.c,v
retrieving revision 1.10
diff -u -r1.10 cmdlinepart.c
--- drivers/mtd/cmdlinepart.c	29 May 2003 09:25:22 -0000	1.10
+++ drivers/mtd/cmdlinepart.c	31 Jul 2003 23:48:20 -0000
@@ -241,6 +241,7 @@
 				&num_parts,	/* out: number of parts */
 				0,		/* first partition */
 				(unsigned char**)&this_mtd, /* out: extra mem */
+				__alignof__(*this_mtd) - 1 +
 				mtd_id_len + 1 + sizeof(*this_mtd));
 		if(!parts)
 		{
@@ -252,7 +253,21 @@
 			 * unlikely to succeed in parsing any more
 			 */
 			 return 0;
-		 }
+		}
+
+		if ((unsigned long)(this_mtd) & (__alignof__(*this_mtd) - 1))
+		{
+			/* Some archs do not allow non-aligned accesses
+			 * within the kernel. So make sure we're properly
+			 * aligned here.
+			 */
+			unsigned long fixup = (unsigned long) this_mtd;
+			dbg(("this_mtd: 0x%0x\n", this_mtd));
+			fixup += __alignof__(*this_mtd) - 1;
+			fixup &= ~(__alignof__(*this_mtd) - 1);
+			this_mtd = (struct cmdline_mtd_partition *) fixup;
+			dbg(("this_mtd: 0x%0x (aligned)\n", this_mtd));
+		}
 
 		/* enter results */	    
 		this_mtd->parts = parts;

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

end of thread, other threads:[~2003-08-01 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-01  0:02 kernel oops due to aligment error in cmdlinepart.c George G. Davis
2003-08-01 13:24 ` David Woodhouse

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