From patchwork Mon Nov 30 11:11:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Hundeb=C3=B8ll?= X-Patchwork-Id: 1408155 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=pass (p=none dis=none) header.from=geanix.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=geanix.com header.i=@geanix.com header.a=rsa-sha256 header.s=first header.b=OO0cjfj0; 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cl2cs3jcCz9sTR for ; Mon, 30 Nov 2020 22:12:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D930825F4; Mon, 30 Nov 2020 12:11:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=geanix.com 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=geanix.com header.i=@geanix.com header.b="OO0cjfj0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 105B582639; Mon, 30 Nov 2020 12:11:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from first.geanix.com (first.geanix.com [116.203.34.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2C9B8825EA for ; Mon, 30 Nov 2020 12:11:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=geanix.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=martin@geanix.com Received: from zen.localdomain (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id 28C714831A0; Mon, 30 Nov 2020 11:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1606734705; bh=CAa+f46gDGA+nYMgOq2r1bLNY3cLHeOYbp08jGFPWnM=; h=From:To:Cc:Subject:Date; b=OO0cjfj0NjADTBU1njPfDqhynuRov/LvG9WVRAMOXWCk9HWgjVwN2PImIENNgUI/A 9DC2rC4q3ykbyrWDipmhtHW6cAUxw2KW2d+fnwAb9Dhk0F1+qU4XB6nqSrfgwXOMzk sQvJ/QAbMsWK/IDTWcWWfi4R0pl7U+Liw4dCOLg28Wmp4SFHlO2O7FTuY5+YjXJobz vtJl67FjEID9hY4tHxGb/SgVSk4VjWgRmjlCuP9D5rBzCHoIxFh0VwW+ZWjcBNSbh1 +5AcsfPQraq2XPmWMd/8cnaPgiwQEKZwL0FBT1ymcUihF1SrwNTLLyGpfyrK3x74YQ VTGxc1lPPT54w== From: =?utf-8?q?Martin_Hundeb=C3=B8ll?= To: u-boot@lists.denx.de Cc: =?utf-8?q?Martin_Hundeb=C3=B8ll?= Subject: [PATCH] tools: env: return error if ubi_update_start() fails Date: Mon, 30 Nov 2020 12:11:32 +0100 Message-Id: <20201130111132.2870658-1-martin@geanix.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The UBI_IOCVOLUP ioctl can fail if exclusive access to the volume isn't obtained. If this happens, the flush operation doesn't return error, leaving the caller without knowledge of missing flush. Fix this by forwarding the error (-1) from ubi_update_start(). Fixes: 34255b92e6e ("tools: env: Add support for direct read/write UBI volumes") Signed-off-by: Martin Hundebøll --- tools/env/fw_env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 66cb9d2a25..2a61a5d6f0 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -1208,7 +1208,7 @@ static int flash_write(int fd_current, int fd_target, int dev_target) if (IS_UBI(dev_target)) { if (ubi_update_start(fd_target, CUR_ENVSIZE) < 0) - return 0; + return -1; return ubi_write(fd_target, environment.image, CUR_ENVSIZE); }