From 899fb5aa8becc159b1eb086d8828c4e8eb28f121 Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Tue, 16 May 2023 05:52:36 -0600 Subject: 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 --- cmd/legacy-mtd-utils.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cmd/legacy-mtd-utils.c') diff --git a/cmd/legacy-mtd-utils.c b/cmd/legacy-mtd-utils.c index ac7139f84d..5903a90fe5 100644 --- a/cmd/legacy-mtd-utils.c +++ b/cmd/legacy-mtd-utils.c @@ -88,6 +88,11 @@ int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off, return -1; } + if (*size == 0) { + debug("ERROR: Invalid size 0\n"); + return -1; + } + print: printf("device %d ", *idx); if (*size == chipsize) -- cgit v1.2.3