summaryrefslogtreecommitdiff
path: root/cmd/sf.c
diff options
context:
space:
mode:
authorAshok Reddy Soma <[email protected]>2023-05-16 05:52:36 -0600
committerTom Rini <[email protected]>2023-05-31 17:23:01 -0400
commit899fb5aa8becc159b1eb086d8828c4e8eb28f121 (patch)
treeea122b175593aaba4252f03c8f8ae83304e3021f /cmd/sf.c
parent2f27405902894c3cb1b274536d623c286aa7c425 (diff)
cmd: sf/nand: Print and return failure when 0 length is passed
For sf commands, when '0' length is passed for erase, update, write or read, there might be undesired results. Ideally '0' length means nothing to do. So print 'ERROR: Invalid size 0' and return cmd failure when length '0' is passed to sf commands. Same thing applies for nand commands also. Example: ZynqMP> sf erase 0 0 ERROR: Invalid size 0 ZynqMP> sf write 10000 0 0 ERROR: Invalid size 0 ZynqMP> sf read 10000 0 0 ERROR: Invalid size 0 ZynqMP> sf update 1000 10000 0 ERROR: Invalid size 0 ZynqMP> Signed-off-by: Ashok Reddy Soma <[email protected]>
Diffstat (limited to 'cmd/sf.c')
-rw-r--r--cmd/sf.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/cmd/sf.c b/cmd/sf.c
index 11b9c25896a..55bef2f7699 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -353,6 +353,11 @@ static int do_spi_flash_erase(int argc, char *const argv[])
if (ret != 1)
return CMD_RET_USAGE;
+ if (size == 0) {
+ debug("ERROR: Invalid size 0\n");
+ return CMD_RET_FAILURE;
+ }
+
/* Consistency checking */
if (offset + size > flash->size) {
printf("ERROR: attempting %s past flash size (%#x)\n",