misaligned memory access in cmdlinepart.c

Timofei V. Bondarenko tim at ipi.ac.ru
Tue Jun 7 07:34:45 EDT 2005


On Tue, 2005-06-07 at 13:01 +0400, Vitaly Wool wrote:
> Hi Timofei,
> I guess you should use a mail client that doesn't expand tabs to spaces, 
> like sylpheed or pine.
> 
> >> JЖrn Engel wrote:
> >>
> >> Doesn't apply with patch -p1.  Can you respin the patch against mtd
> >> cvs and make sure it does?  If in doubt, read:
> >> http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt

I'm apologize for my unusual inaccuracy.
Now, the tabs are preserved; patch -p1 looks happy.
For cvslog:

---
the this_mtd structure should be aligned
---

diff -u -p -r1.17 cmdlinepart.c
--- mtd/drivers/mtd/cmdlinepart.c	26 Nov 2004 11:18:47 -0000	1.17
+++ mtd/drivers/mtd/cmdlinepart.c	7 Jun 2005 08:02:00 -0000
@@ -239,7 +239,8 @@ static int mtdpart_setup_real(char *s)
 				&num_parts,	/* out: number of parts */
 				0,		/* first partition */
 				(unsigned char**)&this_mtd, /* out: extra mem */
-				mtd_id_len + 1 + sizeof(*this_mtd));
+				mtd_id_len + 1 + sizeof(*this_mtd) + 
+				sizeof(void*)-1 /*alignment*/);
 		if(!parts)
 		{
 			/*
@@ -252,7 +253,10 @@ static int mtdpart_setup_real(char *s)
 			 return 0;
 		 }
 
-		/* enter results */	    
+		/* align this_mtd */
+		this_mtd = (struct cmdline_mtd_partition *) 
+		     ALIGN((unsigned long)this_mtd, sizeof(void*));
+		/* enter results */
 		this_mtd->parts = parts;
 		this_mtd->num_parts = num_parts;
 		this_mtd->mtd_id = (char*)(this_mtd + 1);






More information about the linux-mtd mailing list