Skip to contentSkip to conversation

Recent patch to cfi.h screws MTD CFI layer

PATCH Russell King 2 participants 2 messages Nov 24, 2000 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

The recent patch in 2.4.0-test11 causes MTD to oops the kernel:

diff -u --recursive --new-file v2.4.0-test10/linux/include/linux/mtd/cfi.h linux/include/linux/mtd/cfi. h

include/linux/mtd/cfi.h Tue Nov 7 10:46:04 2000 renamed from linux/include/linux/mtd/cfi.h Tue Jul 4 10:12:34 2000 +1 -0
@@ -92,6 +92,7 @@
        int numchips;
        unsigned long chipshift; /* Because they're of the same type */
        struct flchip chips[0];  /* per-chip data structure for each chip */
+       const char *im_name;     /* inter_module name for cmdset_setup */
 };
 
 #define MAX_CFI_CHIPS 8 /* Entirely arbitrary to avoid realloc() */

This is what happens to chips[].start during initialisation:

chip 0 start 0
chip 1 start 800000
chip 2 start 1000000
chip 3 start 1800000
Intel/Sharp Extended Query Table at 0x0031
chip 0 start c013b45c <--- overwritten by write to im_name
chip 1 start 800000
chip 2 start 1000000
chip 3 start 1800000
chip 0 start c013b45c
chip 1 start 800000
chip 2 start 1000000
chip 3 start 1800000
number of CFI chips: 4
chip 0 start c013b45c
chip 1 start 800000
chip 2 start 1000000
chip 3 start 1800000

Here is a patch that fixes the problem, and includes a warning to tell people not to add extra fields after the "chips" element.

include/linux/mtd/cfi.h +2 -1
@@ -209,8 +209,9 @@
 				  must be of the same type. */
 	int numchips;
 	unsigned long chipshift; /* Because they're of the same type */
-	struct flchip chips[0];  /* per-chip data structure for each chip */
 	const char *im_name;	 /* inter_module name for cmdset_setup */
+	struct flchip chips[0];  /* per-chip data structure for each chip */
+	/* do not add extra fields after "chips" */
 };
 
 #define MAX_CFI_CHIPS 8 /* Entirely arbitrary to avoid realloc() */

_____

  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [email protected]      --- ---
  | | | | http://www.arm.linux.org.uk/personal/aboutme.html   /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 1 line · Russell King

The recent patch in 2.4.0-test11 causes MTD to oops the kernel:

Fixed in my tree. That and other things will be fixed when I flush the latest CFI code to Linus - probably quite soon.

The inter_module_ stuff has introduced link order dependencies too. I'm working on fixing that.

Signature · 7 lines
dwmw2


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/