From patchwork Tue Jan 25 17:13:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1584201 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=L4XzudwI; dkim-atps=neutral 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=) 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)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jjtln6CxVz9t5H for ; Wed, 26 Jan 2022 04:15:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1C7D5838EE; Tue, 25 Jan 2022 18:14:10 +0100 (CET) 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="L4XzudwI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3EA4C830D0; Tue, 25 Jan 2022 18:13:44 +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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 C118D83373 for ; Tue, 25 Jan 2022 18:13:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@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 B2B7D6091C; Tue, 25 Jan 2022 17:13:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CF02C36AE7; Tue, 25 Jan 2022 17:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643130814; bh=wmPSIK9YECmWl39FFphIt3GCpLrEFFuK01DxICm8RZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L4XzudwIbm8dY0zghQDURdS1jpTrbEghOBn6TA/qVC/OwA3z89gPdqfP/n2vtbx+P wvLtxe9jJPrvMQ+hqGiUX3pLsksLpSwY8CNqaxQZhXktsOuRF1JiQymi7HnC3gAQgJ 9phKMLcrGwJEcGDkCoMT1Uz1+wLkw05/pzKE1j3VXg25qJUQTjaEQ+rRdQJTu2Jiwc yWfCdgf22/oZy1lQZlhLmTt1042OhzCcR3QsDZ0JlkNpgkQno8k3yTMqlawwow/Odl I0swNOfM4L4sgRE4KGmEKF7p7AgIkFpPb/YCtjTMtWfkag3XobZo67iEtQmBTPgXKw Bc4VMWhSYLDRg== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Stefan Roese Cc: u-boot@lists.denx.de, pali@kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-marvell 11/14] tools: kwboot: Handle EINTR in kwboot_write() Date: Tue, 25 Jan 2022 18:13:10 +0100 Message-Id: <20220125171313.14498-12-kabel@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125171313.14498-1-kabel@kernel.org> References: <20220125171313.14498-1-kabel@kernel.org> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The write() syscall may be interrupted. Handle EINTR and retry it. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwboot.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index de433c1b04..8b748f0fdd 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -292,13 +292,15 @@ static int blk_rsp_timeo = KWBOOT_BLK_RSP_TIMEO; static ssize_t kwboot_write(int fd, const char *buf, size_t len) { - size_t tot = 0; + ssize_t tot = 0; while (tot < len) { ssize_t wr = write(fd, buf + tot, len - tot); - if (wr < 0) - return -1; + if (wr < 0 && errno == EINTR) + continue; + else if (wr < 0) + return wr; tot += wr; }