aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/io.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index b4d34ba60608..35da5aadbe10 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -1387,35 +1387,40 @@ int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
1387{ 1387{
1388 size_t read; 1388 size_t read;
1389 int err; 1389 int err;
1390 void *buf;
1390 loff_t addr = (loff_t)pnum * ubi->peb_size + offset; 1391 loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
1391 1392
1392 mutex_lock(&ubi->dbg_buf_mutex); 1393 buf = __vmalloc(len, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL);
1393 err = ubi->mtd->read(ubi->mtd, addr, len, &read, ubi->dbg_peb_buf); 1394 if (!buf) {
1395 ubi_err("cannot allocate memory to check for 0xFFs");
1396 return 0;
1397 }
1398
1399 err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
1394 if (err && err != -EUCLEAN) { 1400 if (err && err != -EUCLEAN) {
1395 ubi_err("error %d while reading %d bytes from PEB %d:%d, " 1401 ubi_err("error %d while reading %d bytes from PEB %d:%d, "
1396 "read %zd bytes", err, len, pnum, offset, read); 1402 "read %zd bytes", err, len, pnum, offset, read);
1397 goto error; 1403 goto error;
1398 } 1404 }
1399 1405
1400 err = ubi_check_pattern(ubi->dbg_peb_buf, 0xFF, len); 1406 err = ubi_check_pattern(buf, 0xFF, len);
1401 if (err == 0) { 1407 if (err == 0) {
1402 ubi_err("flash region at PEB %d:%d, length %d does not " 1408 ubi_err("flash region at PEB %d:%d, length %d does not "
1403 "contain all 0xFF bytes", pnum, offset, len); 1409 "contain all 0xFF bytes", pnum, offset, len);
1404 goto fail; 1410 goto fail;
1405 } 1411 }
1406 mutex_unlock(&ubi->dbg_buf_mutex);
1407 1412
1413 vfree(buf);
1408 return 0; 1414 return 0;
1409 1415
1410fail: 1416fail:
1411 ubi_err("paranoid check failed for PEB %d", pnum); 1417 ubi_err("paranoid check failed for PEB %d", pnum);
1412 ubi_msg("hex dump of the %d-%d region", offset, offset + len); 1418 ubi_msg("hex dump of the %d-%d region", offset, offset + len);
1413 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 1419 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1);
1414 ubi->dbg_peb_buf, len, 1);
1415 err = -EINVAL; 1420 err = -EINVAL;
1416error: 1421error:
1417 ubi_dbg_dump_stack(); 1422 ubi_dbg_dump_stack();
1418 mutex_unlock(&ubi->dbg_buf_mutex); 1423 vfree(buf);
1419 return err; 1424 return err;
1420} 1425}
1421 1426