From patchwork Wed Apr 12 07:51:54 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: 1767950 X-Patchwork-Delegate: jagannadh.teki@gmail.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=85.214.62.61; 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=Zt/K+SYe; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4PxFLY6q6Nz1yZZ for ; Wed, 12 Apr 2023 17:52:53 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A2EB85DA9; Wed, 12 Apr 2023 09:52:50 +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="Zt/K+SYe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D36485F46; Wed, 12 Apr 2023 09:52:47 +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 autolearn=no autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20612.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::612]) (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 A3F8685DA9 for ; Wed, 12 Apr 2023 09:52:44 +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=LXNEtShORhj3qGMAz07MyChJ3e7cQuFFIBouRW1auDGzTlT5SaxHEka4foBVo/FpfPKfRZNDImZJywUnyd87BrEUT9B67+PU8yOAoIRxlSBcYrHiaouJPVy3hbbn8F1Uu2ObVSgNnB6fEI/Zr39NNwMSSBiI5la/mFUqPJWuufLHFQJlw1ZmxHisIic6zJogp37xL64mAIUwzABHpdrVmi9k9Qm8YBub2/WNMCfEm5xzCVG0FzAYfDtgXKdEPypYFkisOPn/oxso+adCxn/uAzKGPpqFXrLaaXXGN2kNC7veQfcsRwTLZX+Ti8Edh9oo1C0u+FKoKEAge3mn0hFeTg== 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=nNfRJEEnNSceq+54954YtpSBZoInEA2+1HOjZZAWiRg=; b=B7L2DdrB4y9u8H5DJ9+XkuTkU8odruAX8K14M1XpJox9oO3Ayt1kOc/U7c9Cmnd+YImJgZuxqafkA9Zlo2aG6xXRPfKq9oAyeWfULhpVaaLuKWKhuhnpxKf1Go4lx4TN3pykycyWdhtTza3483B4MFK6yO7dvO1qjBVtICKoO48jI+kVV9bSNwKdmFO8Zx9RcpnNZbK7ipHinHYboCzmeaOd9x8425OSiVVJ4zuV1PYRNWXrOOE32b+pbBqOTaY7KOyKt5/bC2y6REaxtjiX+KOlRVSHLM2o/RvBcIE1mWWP5G1xZtszUtUWmDRf0yGvE/N+R5/u2fQ5ciucHJCAIw== 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=nNfRJEEnNSceq+54954YtpSBZoInEA2+1HOjZZAWiRg=; b=Zt/K+SYe+uh4GYP8fI0/0fYA30pkDSE5qW2rg6VkoPhHYAuPwOXEed/ROqjJNCtQI/gln5fzZBDUnxvJRqPN7Zz5XTpkdN4hsC2JlJypMQwixMCVzza0QWCwXDr79qDYcbQ7dZOjBzDQquMhD2X7oM6b8Z+WG2/GGoMy+/EMFjk= Received: from CY5PR15CA0209.namprd15.prod.outlook.com (2603:10b6:930:82::27) by DM4PR12MB5167.namprd12.prod.outlook.com (2603:10b6:5:396::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36; Wed, 12 Apr 2023 07:52:40 +0000 Received: from CY4PEPF0000C976.namprd02.prod.outlook.com (2603:10b6:930:82:cafe::8f) by CY5PR15CA0209.outlook.office365.com (2603:10b6:930:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Wed, 12 Apr 2023 07:52:40 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000C976.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.25 via Frontend Transport; Wed, 12 Apr 2023 07:52:39 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 12 Apr 2023 02:52:10 -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; Wed, 12 Apr 2023 02:52:07 -0500 From: Ashok Reddy Soma To: CC: , , , , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2] cmd: sf/nand: Print and return failure when 0 length is passed Date: Wed, 12 Apr 2023 01:51:54 -0600 Message-ID: <20230412075154.13783-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: CY4PEPF0000C976:EE_|DM4PR12MB5167:EE_ X-MS-Office365-Filtering-Correlation-Id: b97c59f0-258f-47e2-11d0-08db3b2ae39f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 09rZRZAXsPRnZi+rSGFOOO4VRcP7N5bwb8oTCInOnS+nwXzRZB7C/5PkdCPN6lNgjOrw8A8ekClhtvdUqUG7aKmU81GAApuwjLx3YA0VvEdah2o8a6S7VfP4xrPUmCEIf5M26t3U0blSRrbU/ydKc9rtFJ72oaS2rmXtgy4m4pHmB+pWLrK2Oc9HGVDirF7dAFCYgkqTPvg/3bQE/mDFHXkCq4H+1QbN6wkU/PkuIrvMD9F4x+5iVvIQwgFUDMUhV5Ddyi2SvyF0dRkDnmRf2bxKUEV9rI3tPYBcx/XXRD6PF4jZ72Clr5J6zJqdAWGjd/FmfRsY2Gq7R2MXdOTtAK6zZd1hA0GiTmLGs2aOkUnjK0HMPBiycLyV4orITRZvbrtG5XKBS3YkiN9Z1D0IGrWSpqB0a/dxnW3MRAEvuTAe+hs+mOfsSnLaC0+CXJ5PuMW/SjlMxIyeuysPC8tHkPi1Q5LaHTgz622c+kpT7UAPGDIJO+ZW3jhFeGCKmVm4g02ka8akp1Mf6I7Dq6c0UXCkPM+BZ4gKUmyfo3WKaGoAW8nlAlPHVRYlTAGNhjKbgnnmYi9oPi8guV4PR/f+h3xYvNrX6pE154Q419nNNTtMs6iw3924ktPf/deOHKwWOOJwhAZaw+VYlxK3lhWv1vUdukHp22wc/0InQlsggdh+MARDet76LVNCf8QeBhmLDs2GmXvqXqqT5JQnQIvppPGLDOoPSVHk3Vg3sTttoX4= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(36756003)(86362001)(103116003)(316002)(70206006)(41300700001)(54906003)(8676002)(4326008)(478600001)(6916009)(70586007)(40480700001)(5660300002)(36860700001)(82310400005)(8936002)(2906002)(81166007)(47076005)(82740400003)(356005)(186003)(83380400001)(26005)(1076003)(6666004)(2616005)(336012)(426003)(66899021)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2023 07:52:39.5482 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b97c59f0-258f-47e2-11d0-08db3b2ae39f 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000C976.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5167 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 Acked-by: Michal Simek --- 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..61987918a4 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) { + printf("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..a6aadc2b00 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) { + printf("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",