misaligned memory access in cmdlinepart.c
Jörn Engel
joern at wohnheim.fh-wedel.de
Tue Jun 7 09:02:16 EDT 2005
On Tue, 7 June 2005 12:30:13 +0400, Timofei V. Bondarenko wrote:
>
> Ok, sorry for noise.
> Is it good enough?
Still broken. You have some whitespace noise in it.
I could easily fix it up, but I feel like a bastard and prefer to
share the pain. If your mail reader is screwing it up, you can send
the patch as an attachment. Inline would be preferred, though.
> 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);
>
>
Jörn
--
I've never met a human being who would want to read 17,000 pages of
documentation, and if there was, I'd kill him to get him out of the
gene pool.
-- Joseph Costello
More information about the linux-mtd
mailing list