Browse Source

Merge tag 'mtd/fixes-for-4.16' of git://git.infradead.org/linux-mtd

Pull MTD fixes from Boris Brezillon:
 "Two fixes, one in the atmel NAND driver and another one in the
  CFI/JEDEC code.

  Summary:

   - Fix a bug in Atmel ECC engine driver

   - Fix a bug in the CFI/JEDEC driver"

* tag 'mtd/fixes-for-4.16' of git://git.infradead.org/linux-mtd:
  mtd: jedec_probe: Fix crash in jedec_read_mfr()
  mtd: nand: atmel: Fix get_sectorsize() function
Linus Torvalds 7 years ago
parent
commit
ab12762b19
2 changed files with 3 additions and 1 deletions
  1. 2 0
      drivers/mtd/chips/jedec_probe.c
  2. 1 1
      drivers/mtd/nand/atmel/pmecc.c

+ 2 - 0
drivers/mtd/chips/jedec_probe.c

@@ -1889,6 +1889,8 @@ static inline u32 jedec_read_mfr(struct map_info *map, uint32_t base,
 	do {
 	do {
 		uint32_t ofs = cfi_build_cmd_addr(0 + (bank << 8), map, cfi);
 		uint32_t ofs = cfi_build_cmd_addr(0 + (bank << 8), map, cfi);
 		mask = (1 << (cfi->device_type * 8)) - 1;
 		mask = (1 << (cfi->device_type * 8)) - 1;
+		if (ofs >= map->size)
+			return 0;
 		result = map_read(map, base + ofs);
 		result = map_read(map, base + ofs);
 		bank++;
 		bank++;
 	} while ((result.x[0] & mask) == CFI_MFR_CONTINUATION);
 	} while ((result.x[0] & mask) == CFI_MFR_CONTINUATION);

+ 1 - 1
drivers/mtd/nand/atmel/pmecc.c

@@ -426,7 +426,7 @@ static int get_strength(struct atmel_pmecc_user *user)
 
 
 static int get_sectorsize(struct atmel_pmecc_user *user)
 static int get_sectorsize(struct atmel_pmecc_user *user)
 {
 {
-	return user->cache.cfg & PMECC_LOOKUP_TABLE_SIZE_1024 ? 1024 : 512;
+	return user->cache.cfg & PMECC_CFG_SECTOR1024 ? 1024 : 512;
 }
 }
 
 
 static void atmel_pmecc_gen_syndrome(struct atmel_pmecc_user *user, int sector)
 static void atmel_pmecc_gen_syndrome(struct atmel_pmecc_user *user, int sector)