From patchwork Wed Apr 12 07:13:48 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: 1767923 X-Patchwork-Delegate: dario.binacchi@amarulasolutions.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=mrM44ZYL; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PxDVJ4G7Gz1yZK for ; Wed, 12 Apr 2023 17:14:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B7B5E85F3D; Wed, 12 Apr 2023 09:14:24 +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="mrM44ZYL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 95A3E85F55; Wed, 12 Apr 2023 09:14:22 +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 NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e83::60c]) (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 615D685F3D for ; Wed, 12 Apr 2023 09:14:19 +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=Q6EBB3JJTWBfGGMw7WXiHjlbbvDX1rs6m0EH1V4ytNrAurQbJs+8656+3Vy+XnPLkvsfqSKVwm5qQLE4PoT03oCiV0TKDDxYnD7t4JfUKP1b4sM7V7WJ3UTRxYi96ACgjmnCGHvyjfbn0UiETNnpj1C2jJCcPz5/cAin4yobczQ1wUzchpfz/0dSipuKggghcPRhWFmQzi6FmU+aBwQl/Q0gd3lgaB1klOXfUNxta/mY8WreUSVkRIQqA7aQXYKYMKfD3L0EHMhnQf4sk/cfTfROgF5KlKrfFud4fcOCEHlV2LHpUXq9HGK2vv6zd4hzk+VMp7Cr+M3xAKImXEEPFg== 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=NfvA9O5IeSJ/uEtglJnrPs5noOKNwZGrGiwAL2srOeM=; b=hJKIYMipWVr+H0sVJjst3c45mP0781U75ujfwEY3hCY9OaAhMwJvMpge0p/vPCfPggEWZH/AXcJTT3dkHsNJvzLNpl4zMtiOEKSBKN/YX2j9HbyJqZ9ggKZ4gormYqY6Q+ciaThSpv4q982tdLEeA7GFhdGr0Wt9sULkE5hb72EKiH/gUKbbjYf3JGjtQCmYJDj75zl1g+NSL/n+i2Tc79WgGXc4Afkg4Gkb3ofZbUui6GYqhqjJlnzKLTUicj2owb/QgMGjVyiiVTbLuVjrOx0HKk0b+NZAUb2mKpf/XeKY5rcyd1ozHGhItQveh+Kqe2Is4aQvFdbApU0euN0rBg== 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=NfvA9O5IeSJ/uEtglJnrPs5noOKNwZGrGiwAL2srOeM=; b=mrM44ZYLqLHDfhDHdR9sQ39N+KN6QPENGKGPxg2i+r+D9Umy24yJUf60y1xDzmpcvRiYk/A11F30+7a/Ef2v19Qb/U9wel57y8bsgdEMYOxEiIQzwMx3ej+O9Mc6jp5cs5je7Gr5CRHCAmP8SiXhTh+6uVI30ASsIOYFWITnI1Y= Received: from BN1PR13CA0006.namprd13.prod.outlook.com (2603:10b6:408:e2::11) by SJ0PR12MB8168.namprd12.prod.outlook.com (2603:10b6:a03:4e7::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Wed, 12 Apr 2023 07:14:16 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::e7) by BN1PR13CA0006.outlook.office365.com (2603:10b6:408:e2::11) 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:14:15 +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 BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.28 via Frontend Transport; Wed, 12 Apr 2023 07:14:15 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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:14:10 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) 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:13:59 -0500 Received: from xhdashokred41.xilinx.com (10.180.168.240) 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 via Frontend Transport; Wed, 12 Apr 2023 02:13:57 -0500 From: Ashok Reddy Soma To: CC: , , , , , , , , , Ashok Reddy Soma Subject: [PATCH] cmd: sf/nand: Print and return failure when 0 length is passed Date: Wed, 12 Apr 2023 01:13:48 -0600 Message-ID: <20230412071348.8666-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: BN8NAM11FT014:EE_|SJ0PR12MB8168:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d80b36a-07cd-4228-3592-08db3b258640 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iirmpqQHJ4PjLAXKFoMYi7sXinaGRRLqPz92dGuP9vLuSOM2q+mrxlHqx+4uLncHCHqdKsWy/4rprT4tZAq6K3vU4VFpX1UpQCLbc4q932n8QNoInsReCoFmCFCvaADfE5gLw1POh2jJ6X7elkZcZvlgnXeBavM0ZaR2gKtXvk8yaaKZ6kI1vHKF4ENJ9Qhq0UxIdNaB/jN1GSglJxd5u4oLoMqD2V9GBzXLZF4d5fBuh6RWW2zg989ae+4IQHb3Y6JSxAQnps2nnkrsHfx4yhU5kJ57PgnrMW8bQwn/L3s1u4Vqnw3pt3RlOPlRAGEjd6nP/FyQGdWKEGqhdXpt4VeOU1M8hZ5IQUOjg9j+POqS1WBLwFc5Wp/aeBZpeUgGcXPBJUp6DG+7Y/9aYf6X6YoXqu0yC80txE0BCz6PPHgqFbSdAkTlmxydNpC9WLKgstgt51MPSF/EbLQBX9TAg3pY3DRZXjH6rwtEeDEbKE9hX5AFjB8qKf5Pskt0jyVFuMeglof8/x9PtBURDPUO+OO/7BLbZ48t7yZTwjP09ahSfZSGnuVtR8v71dqMD3FiTO8IatqEU//uT138DbU6ggqXC2Ao2Lt+uLiQeObHUTg38cqeQ1m9k5y+CmixedvPrgSOQxfgsOcuNZV5yCMCIa2wBHpbUjt+8qHg1iNNcVmHLDvkodUqPfx4FzLxlQlDRASecEdKj7mlVcJpY5DbkyFmXgMghGLeVlYpza8oJL0= 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)(39860400002)(396003)(136003)(376002)(346002)(451199021)(40470700004)(36840700001)(46966006)(6916009)(26005)(1076003)(70206006)(4326008)(66899021)(86362001)(70586007)(316002)(186003)(40460700003)(36756003)(6666004)(54906003)(40480700001)(36860700001)(478600001)(103116003)(8936002)(8676002)(2616005)(356005)(41300700001)(5660300002)(81166007)(2906002)(47076005)(82310400005)(426003)(336012)(83380400001)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2023 07:14:15.4303 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d80b36a-07cd-4228-3592-08db3b258640 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: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8168 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, we might see undesired results. Ideally '0' length means nothing to do. So print 'size is 0' and return cmd failure when length '0' is passed to sf commands. Samething applies for nand commands also. Example: ZynqMP> sf erase 0 0 'size is 0' ZynqMP> sf write 10000 0 0 'size is 0' ZynqMP> sf read 10000 0 0 'size is 0' ZynqMP> sf update 1000 10000 0 'size is 0' ZynqMP> Signed-off-by: Ashok Reddy Soma --- 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..7b49bfd858 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("'size is 0'\n"); + return -1; + } + print: printf("device %d ", *idx); if (*size == chipsize) diff --git a/cmd/sf.c b/cmd/sf.c index 11b9c25896..46b5475fe8 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("'size is 0'\n"); + return CMD_RET_FAILURE; + } + /* Consistency checking */ if (offset + size > flash->size) { printf("ERROR: attempting %s past flash size (%#x)\n",