From patchwork Tue May 16 11:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Reddy Soma X-Patchwork-Id: 1781992 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=BcxgP7jb; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QLF3y5qWXz20KF for ; Tue, 16 May 2023 21:53:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 71C6C860F4; Tue, 16 May 2023 13:52:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="BcxgP7jb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 34A16860C7; Tue, 16 May 2023 13:52:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20626.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::626]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0498486139 for ; Tue, 16 May 2023 13:52:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=ashok.reddy.soma@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gSzVzTO482s3Fqupz8yn3AcGZV3CZ90hDhypt+Mxl5lVNswf16v8QPOLX1DbnqAnDnF2A5mYM99Uqm6qI+mFjya/ggaVo9X7hxVnBC47iCPxW1Ece/RDEZCsFPekfBCIXHFKExBeVcXyN2WAZ/Zik2q5ElKcGLsWMTPiPcivDmBxpcvU1tVf/W2VtnFDCRfrcdt6r+3+10l6f5uYKIbvgxny1UXFj+J+svqXCi3Og6oGQx81m9AzpbtgYKJBhNu6GHccvZB2e3RLG0+xLFFytiUet0+TVrC7+8DRGY864OVmrJkLA+cNrn2FYLSS8VzvF3wl2bsw8thQ+1TeTJ65TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6/aPFmmHnKUagDo+HVR81o39SlOAI4Y5tgwQa9O0TRc=; b=D8Q0C5NlFkExInTG/LAu6XzR1M14SBJcdwCPQZC2/HECSgivSiKLwznyY7bULNL6v0+pwvwAOYnZTP0wGC/TcXeZyLTNBIfYK0rBEFuObBfKAIe3U8JS0WYkqMDMn7MwMkM2NRsJ11BkHhOYkVKJEkMALtWEOFHehyfenZDb3vBspChwMQsh8rW2dm9bA4EkvGgcpYppJU7QU5/7h8DB/rG71ZmFsgVufsAB4gy8Xb4pO+mZNBGJMK/HXU+IzD/xhwEPn7DYe7Zjn9dBplfLKmHCK4qb4ynV8egPyjl2h/QUxN+4BL6X41c+wHIcz9ljPWwbDzWVBChcyBcPEstNSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6/aPFmmHnKUagDo+HVR81o39SlOAI4Y5tgwQa9O0TRc=; b=BcxgP7jbIEHC5XoVgfFKu1hbb9ssIqmLTbhVDfW4I0KGnYwSvNjehROzuAiMC+y9mX9qeX+1WwfCY/f3gX/tN7TUhfAFCLHLgM+H7Mi0HG9DYbKn2T5vPdGSnE9ii2dkQuRAA+QkXqyO/O5GCiVytf8qKlRcufH8u8JePlU7y6c= Received: from DM5PR08CA0053.namprd08.prod.outlook.com (2603:10b6:4:60::42) by BL1PR12MB5754.namprd12.prod.outlook.com (2603:10b6:208:391::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Tue, 16 May 2023 11:52:50 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:4:60:cafe::f) by DM5PR08CA0053.outlook.office365.com (2603:10b6:4:60::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33 via Frontend Transport; Tue, 16 May 2023 11:52:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.15 via Frontend Transport; Tue, 16 May 2023 11:52:49 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 16 May 2023 06:52:47 -0500 Received: from xhdashokred41.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34 via Frontend Transport; Tue, 16 May 2023 06:52:44 -0500 From: Ashok Reddy Soma To: CC: , , , , , , , , Ashok Reddy Soma Subject: [PATCH v3] cmd: sf/nand: Print and return failure when 0 length is passed Date: Tue, 16 May 2023 05:52:36 -0600 Message-ID: <20230516115236.22458-1-ashok.reddy.soma@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT035:EE_|BL1PR12MB5754:EE_ X-MS-Office365-Filtering-Correlation-Id: 58dd3a8e-e660-46cc-1177-08db56041299 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p8N2/wJCmzNXw5qKTvpR/W7lT1/lHTtBVpxbT1+1uAYp3cQNc2dNY0SsCfjAzPj07hhEvi5VIV7HcLFghggl0nxuN7xO9IMnNG4kEJBvK+KC+zSQcZ/Sz6fgXOzy9I/RNsN4hSRv3TFEhaSEb9jShjJPO8fvhX47m8UheakcH+taXhvTbZZNKZr/bJWzOoKrkzvbOe8x/uyQCSHwYl839NY8p5oBR3kR0oTWFvLmQiUx1qxTJcJrzVxvzcPPMspN6KWDP3fRVHne9CAkQJkKtVi6TWRgfW7QMVZLdORj9CZrNVtHrqV3Y/4k3IwidoGHP8R6N5mJXexR3zWKrTPdzJb5qpibpLjRsi3PdNAKd77ne00zTag8SrHBeVgCpDB5Dtnfs+ySU5cw52xY2je12WhdHpdlihpHpRU9JRrQHt+pHfIwfYBcmoSIM8ReIFmjXgx8zUgV926S8q8MV8mL1ISHuPjB+6dUTd1fUtZiHgUpztzP7QVRhVrNOrFbnIm6z/ZDK2kTnHsbIvgvn52DWJYpFuNcuYihZrQWsH5xfqakAI4ISqguedsI9zV6t0CZgxRslAZBLP4RmFS2pU3HfMZsBQFINRfZEgoQuMgbNr6uXb6hup3Fbi8ytVg4ixCiNfeUmUYdaHJ72Kg8VDskgW+svXQu+4n/mplEm7GWvnHLcByC1xtKMz2M9lvPxT7H+iJsNlh+PTyJwNCvWtifTwrkOGKjb7UKU45y8Ner7/7Mz+aO307w6o1dhtu4wHmxH+nTB/uMcN/+bNYGsJRFBw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199021)(46966006)(40470700004)(36840700001)(66899021)(40460700003)(70586007)(70206006)(6916009)(4326008)(478600001)(316002)(54906003)(103116003)(86362001)(36756003)(47076005)(83380400001)(26005)(2616005)(336012)(426003)(36860700001)(1076003)(186003)(41300700001)(8936002)(8676002)(5660300002)(2906002)(6666004)(40480700001)(82310400005)(356005)(81166007)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2023 11:52:49.4155 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58dd3a8e-e660-46cc-1177-08db56041299 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5754 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 --- Changes in v3: - Change printf to debug as it is too verbose Changes in v2: - Changed print from 'size is 0' to Invalid size 0 without quites. - Modified description to be imperative - Fixed typo in description from "samething" to "same thing" cmd/legacy-mtd-utils.c | 5 +++++ cmd/sf.c | 5 +++++ 2 files changed, 10 insertions(+) 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) diff --git a/cmd/sf.c b/cmd/sf.c index 11b9c25896..55bef2f769 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",