From: "George G. Davis" <gdavis@mvista.com>
To: linux-mtd@lists.infradead.org
Subject: kernel oops due to aligment error in cmdlinepart.c
Date: Thu, 31 Jul 2003 20:02:52 -0400 [thread overview]
Message-ID: <3F29AE2C.2020000@mvista.com> (raw)
[-- 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;
next reply other threads:[~2003-08-01 0:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-01 0:02 George G. Davis [this message]
2003-08-01 13:24 ` kernel oops due to aligment error in cmdlinepart.c David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F29AE2C.2020000@mvista.com \
--to=gdavis@mvista.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox