summaryrefslogtreecommitdiffstats
path: root/commands/nand.c
diff options
context:
space:
mode:
authorStefan Christ <s.christ@phytec.de>2016-02-15 11:01:24 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-02-23 07:56:28 +0100
commit53eff047f96a7d1a8eb899619ce659945ab4a7d2 (patch)
tree32393e2409d92205c34697954c3e4d236e1755ba /commands/nand.c
parentcc7a403bf4ceafac80149e3ddf7e05a918258f05 (diff)
downloadbarebox-53eff047f96a7d1a8eb899619ce659945ab4a7d2.tar.gz
barebox-53eff047f96a7d1a8eb899619ce659945ab4a7d2.tar.xz
mtd: core: check offset in mtd_block_markbad
Check if the given offset is valid for the mtd device. Print an error message if not to inform the user in the command 'nand'. Signed-off-by: Stefan Christ <s.christ@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/nand.c')
-rw-r--r--commands/nand.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/commands/nand.c b/commands/nand.c
index ad1c8c9b3d..c330ad1dc4 100644
--- a/commands/nand.c
+++ b/commands/nand.c
@@ -90,8 +90,13 @@ static int do_nand(int argc, char *argv[])
}
ret = ioctl(fd, MEMSETBADBLOCK, &badblock);
- if (ret)
- perror("ioctl");
+ if (ret) {
+ if (ret == -EINVAL)
+ printf("Maybe offset %lld is out of range.\n",
+ badblock);
+ else
+ perror("ioctl");
+ }
close(fd);
return ret;