Skip to contentSkip to conversation

Bug in 2.6.10 mtd driver for physmem mapped flash chips

PATCH New K.F.J. Martens 1 participant 1 message Dec 27, 2004 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bug in 2.6.10 mtd driver for physmem mapped flash chips

The patch below fixes a small but fatal bug in the code that handles non-buswidth-aligned writes. The problem is that the code used the same index in both map_word and buf, therefore putting the wrong words in the map_word that partially contains old data and partially contains new data. The result: corrupt data is being written.

include/linux/mtd/map.h 2004-12-27 15:59:02.631211329 +0100 renamed from include/linux/mtd/map.h 2004-12-24 22:34:31.000000000 +0100 +1 -1
@@ -322,7 +322,7 @@ static inline map_word map_word_load_par
                        bitpos = (map_bankwidth(map)-1-i)*8;
 #endif
                        orig.x[0] &= ~(0xff << bitpos);
-                       orig.x[0] |= buf[i] << bitpos;
+                       orig.x[0] |= buf[i-start] << bitpos;
                }
        }
        return orig;
Signature · 5 lines
K.F.J. Martens, Sonologic, http://www.sonologic.nl/
Networking, embedded systems, unix expertise, artificial intelligence.
Public PGP key: http://www.metro.cx/pubkey-gmc.asc
Wondering about the funny attachment your mail program
can't read? Visit http://www.openpgp.org/