From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4947CC00140 for ; Tue, 26 Jul 2022 14:12:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1C5C9841AA; Tue, 26 Jul 2022 16:12:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ZQt+P0KR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD8478410B; Tue, 26 Jul 2022 16:12:21 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (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 E5E9D840C3 for ; Tue, 26 Jul 2022 16:12:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9B0EA61627; Tue, 26 Jul 2022 14:12:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9BECC433B5; Tue, 26 Jul 2022 14:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658844735; bh=yD74IuvvmwRnau621o1TbNwdFBmJNI1nF29WuSKwD9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQt+P0KRMLaVN3k8E53pIpg3K41qGJPEOu+0NHJ+z9OgVPxGWQg+qEjRivBF5GzOT PfOAB9lOl3rvfC1LxhFHu7yuVQNdaP4iP8kxtyZWNng/zMAm2bnnhu46AHzVVo6MQQ jWGJedDXxuzPrb+Ox0Lrb14Ai6UeT/kyksno+NEexG4H4eSaRpu3JM9t9Jkx3fbAfU WFu9xn4rxfWUR5yxKlM2mBLhg2n5U2OuXyjZQ5VcPkpeV6F/kOxIFelm2YJdHGm0Z2 eFIiMICjpNFOlbFKZp1pLxDFlop+XOnrqPYSzw/k2Gi1aj+WvajLEE/zIfZkqCYEC4 ksTd4sVNl8p4Q== Received: by pali.im (Postfix) id 3AAFF4983; Tue, 26 Jul 2022 16:12:12 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , Michal Simek , Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH 2/4] cmd: mvebu/bubt: Correctly propagate failure during tftp transport Date: Tue, 26 Jul 2022 16:11:57 +0200 Message-Id: <20220726141159.19774-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220726141159.19774-1-pali@kernel.org> References: <20220726141159.19774-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean net_loop() returns signed int type and negative value represents error. tftp_read_file() returns unsigned size_t type and zero value represents error. Casting signed negative value to unsigned size_t type cause losing information about error and bubt thinks that no error happened, and continue erasing SPI-NOR which cause malfunction device. Fix this issue by correctly propagating failure during tftp transport. With this change when there is no eth link, bubt does not erase SPI-NOR anymore. => bubt Burning U-Boot image "flash-image.bin" from "tftp" to "spi" ethernet@30000 Waiting for PHY auto negotiation to complete......... TIMEOUT ! ethernet@30000: No link. Error: Failed to read file flash-image.bin from tftp Signed-off-by: Pali Rohár --- cmd/mvebu/bubt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index a05e22a5479c..2924b1539f32 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -455,11 +455,14 @@ static int is_usb_active(void) #ifdef CONFIG_CMD_NET static size_t tftp_read_file(const char *file_name) { + int ret; + /* * update global variable image_load_addr before tftp file from network */ image_load_addr = get_load_addr(); - return net_loop(TFTPGET); + ret = net_loop(TFTPGET); + return ret > 0 ? ret : 0; } static int is_tftp_active(void) -- 2.20.1