From patchwork Thu Nov 7 12:39:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rini X-Patchwork-Id: 289310 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 986502C00C3 for ; Thu, 7 Nov 2013 23:40:12 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DDA184A339; Thu, 7 Nov 2013 13:40:10 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Se6FCzQT7dk7; Thu, 7 Nov 2013 13:40:10 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4B9334A355; Thu, 7 Nov 2013 13:40:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 86E214A355 for ; Thu, 7 Nov 2013 13:40:03 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Uui3U1x7FFxz for ; Thu, 7 Nov 2013 13:39:57 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-qc0-f171.google.com (mail-qc0-f171.google.com [209.85.216.171]) by theia.denx.de (Postfix) with ESMTPS id 647124A339 for ; Thu, 7 Nov 2013 13:39:50 +0100 (CET) Received: by mail-qc0-f171.google.com with SMTP id i7so323509qcq.16 for ; Thu, 07 Nov 2013 04:39:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=Gv0i5PrCgWLWOQVAtXvGwPWHRkU0bHI7hyVAENVJlWA=; b=v8Se7pHeImQzYQ8VJ1dB2iYydH+7dpDglNdSkaVAVh85AQJ7XbqlPfpzGF9NEEZ2ob B0keOuMJSAstRgwSk9Ar/g09iALhvupmbd++q826k+gg1OX3ZkvBIDoB58Rv+hAn/KBZ dbBfaHja7mk9Q6z9FLV9OXWuqFMhf/VwtU1v2Mmf9SYyRzWysdKz//nee6T1653X6P4k P9iTbFjvRg1veDs/Hu0dSnbpN42SkrjY0acGXAbXBWgDbfYNeNiNhvKl111KyJgm7sUx RDWxC6ivHt1toUEvX8D5mx2RvymQCHxbjwMNBULQnAo9tvSCGkNgYlCJY6bgQs9k4fJ7 iL1g== X-Received: by 10.49.98.1 with SMTP id ee1mr12382049qeb.28.1383827988928; Thu, 07 Nov 2013 04:39:48 -0800 (PST) Received: from localhost.localdomain (cpe-174-106-216-211.ec.res.rr.com. [174.106.216.211]) by mx.google.com with ESMTPSA id 5sm9497845qao.3.2013.11.07.04.39.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 04:39:47 -0800 (PST) From: Tom Rini To: u-boot@lists.denx.de Date: Thu, 7 Nov 2013 07:39:48 -0500 Message-Id: <1383827988-8512-1-git-send-email-trini@ti.com> X-Mailer: git-send-email 1.7.9.5 Subject: [U-Boot] [PATCH] hash.c: Correct non-hash subcommand crc32 addr-save support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de In the case of not having CONFIG_CMD_HASH but having CONFIG_CMD_CRC32 enabled (and not CONFIG_CRC32_VERIFY), we end up in this part of the code path on hash_command(). However, we will only have exactly 3 args here, and 3 > 3 is false, and we will not try and store the hash at the address given as arg #3. The next problem however is that we've been moving argv around so the third value is now in argv[0] not argv[3]. Confirmed on AM335x Beaglebone White. Signed-off-by: Tom Rini --- common/hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/hash.c b/common/hash.c index 722c40b..872cd85 100644 --- a/common/hash.c +++ b/common/hash.c @@ -325,8 +325,8 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag, printf("CRC32 for %08lx ... %08lx ==> %08lx\n", addr, addr + len - 1, crc); - if (argc > 3) { - ptr = (ulong *)simple_strtoul(argv[3], NULL, 16); + if (argc >= 3) { + ptr = (ulong *)simple_strtoul(argv[0], NULL, 16); *ptr = crc; } }