From patchwork Tue Jan 16 11:17:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Salvini X-Patchwork-Id: 1887041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=l+J4fRt2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::f37; helo=mail-qv1-xf37.google.com; envelope-from=swupdate+bncbaabb7gltgwqmgqe5yyhdqy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-qv1-xf37.google.com (mail-qv1-xf37.google.com [IPv6:2607:f8b0:4864:20::f37]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TDmhz1MgTz1yPV for ; Tue, 16 Jan 2024 22:18:25 +1100 (AEDT) Received: by mail-qv1-xf37.google.com with SMTP id 6a1803df08f44-68170c4772dsf7330896d6.1 for ; Tue, 16 Jan 2024 03:18:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705403901; cv=pass; d=google.com; s=arc-20160816; b=DRp48WdtASj9bfSAJfutN7saGOFT7fbkwNiaTSg/zfZLM3F1BGRCz1taLgZIZTBErq CQQxzbLUDV2Njfhwxi0FOKfVN9yM9GKVp0k8Q73awI6mljzUs5KYUASsrTHo9CpCvCTB VSyEkAb610zkCJ6Q/OdwhJkAFFfdl1sMoSWApRKjPyhUc0Jhwpm83ul2GUXtpNBQ0wYP ZuApgyVbxcOCP4Njak2LiWONAoYuQpKjL7eTf3F2dHBvZWZfA9L3NQ/8dCNmJRtrzQQs UxZa7NdNtKEvZCU/sBtZT1LuuR2PhHXbm7nEn6QwFl9SnlvN/FKZROa+OTLCJaYk4CXF aEOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=a26NxeqnHmbVUmqC9Cosz1FnoeM+f59qb4EliaduVkw=; fh=8T9MKhn9nHWOJ2v1CXzPGG/DpFYm2nDcbD4ET2yinps=; b=HcIfojNwE35YYI/3DlqwTOgeif6Xy9q4loSLkH2ambpz65/wtdIlZiAtg/UoWBvquS 3NbaHRLuOwQ/pterNTZABlmTc3fO6Wp5A50LzPEArfSnA+WoVZXDZp02WON21rcggPm9 4KpoagubY1OqFMSE+ejLTyEsdVPhFWVBPbLBVZZeE5WjZkoE7tCH1AKHMoN7kPwRSmUz CuNSfEFq6+tUpBeXSbdEN/fJQZ1pwSig7q0h/lrTKyjI3mqaBHfACIOgmC4YEqQfC3lv eaxb7qJ1zLg+32OnT1gtZ1cHbANIwSiwlWcbMaxAOkvgI3oLYu2h4PkWSRp19rdT1vHa Hrow== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of m.salvini@koansoftware.com designates 172.104.12.216 as permitted sender) smtp.mailfrom=m.salvini@koansoftware.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1705403901; x=1706008701; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=a26NxeqnHmbVUmqC9Cosz1FnoeM+f59qb4EliaduVkw=; b=l+J4fRt2bp+Biz+sKB9s0PmsoTPue4q9N45kyPhW5nvklChiagc5N+FErK2cyZnclz PSiYnovdXnlzEXDAv4oKqQH67SqXYoETah0n6WCvlQMERj6RuvL4CiC/L+Bq/X02Mcmk P0BrOrZ3TcvAgssMekk2CryynH8ZahFKvmowYyXVlOGN4rKSXtJjUp6Ny1mDmj+jPQxA wZ9Xm2qsuvSbw3ZY5tSDXOtx2msJaLC62rJt3X87+iSxgWnclFJHcxM08+kS3OCys6OA BPTgtkHGTx/wi67ZVF573pIKCmcvYC/2/GUbKJoCuqsR6/YStcf4jtrVZk/Nhssmo7tf rnpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705403901; x=1706008701; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=a26NxeqnHmbVUmqC9Cosz1FnoeM+f59qb4EliaduVkw=; b=W+UYvE0tAiZEAn1w06rX71KCa9df9brQZMRmrPf2DgVtMS5dJBWI1zFQbxUccp3Vh+ FbEgig9hDqThAJoFRVRJgsTcF/d5Ro0zwltJxOT+kNXW6msnqjWK0cJH0MzMwK56zrzy SdcMPW4w0Sei3nR8C4FWcu1ho5TsEmkWjvsPO9CEFgzhqCoOg+YKJwStF7DluROvV+kS 1yXATLR2FALGbwiZGGnN83XgH9b0UdjC+r+wRIHoZR46NTTxJ6yZWEAlwGrROEOsv3ue /H4gDEbApZFnqfD8xoMuVS4qRK9JfHxjIsxya3A2v8I9jvowScTGsdhxQGhj4aY8HOax s03A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YzjYxplOt7prZgfJwkMJVykg94q+XRJTnsXD2RZWvf83Vip2zqg y4j8QYQal/VV88lwCH8aP4s= X-Google-Smtp-Source: AGHT+IFL/Blze2sHuzNfWi7jQXYe0RKRaLrYL48l3RNhUHV9gAcBE36mRHDFCPe/U78XaVd3F+uFhQ== X-Received: by 2002:ad4:5f45:0:b0:681:21da:a6e5 with SMTP id p5-20020ad45f45000000b0068121daa6e5mr10440509qvg.0.1705403900697; Tue, 16 Jan 2024 03:18:20 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a0c:b559:0:b0:67a:9173:54f9 with SMTP id w25-20020a0cb559000000b0067a917354f9ls1973475qvd.1.-pod-prod-00-us; Tue, 16 Jan 2024 03:18:19 -0800 (PST) X-Received: by 2002:a05:6214:da2:b0:681:558b:2160 with SMTP id h2-20020a0562140da200b00681558b2160mr7228384qvh.20.1705403899766; Tue, 16 Jan 2024 03:18:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705403899; cv=none; d=google.com; s=arc-20160816; b=aUexRTfe69MB58m9RpE9LGURlRdSt+nQ7DRb+DhtNlCce3wCXdWQQxqzNCtZqi09h2 5g89MvXjFnCzvWK4PrpYMFsOgY1VJWAnbCKZo2fta/m3AxEKQRZEBOhB8W6XsR6LDDUY tihadxji1Dkydq17goPeAPvEJ6DCxPOYBUihohZEcBE4aGwtVh+vT0dRfN92wyKytGzv EMKtsVF9zenGRpjFUrqo6Q9vmAneU5FcfCP8GM+pvAjF2yplPpb2cxGj9yFueiLIYnil yELKlPF903QcBYrVrppo4K2Fn7KObfB3zjZTTvhNoSXqArMtCEgOrOfyr2IEqdcIdy0W AZTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=EbLJPuVwi3vYBVEzDdm9uvRoK4pIpKoQHf2dnTp+Kvo=; fh=8T9MKhn9nHWOJ2v1CXzPGG/DpFYm2nDcbD4ET2yinps=; b=BGZKejgJo9sHoHwx3cB/y2g5SoxRGkcIKFnzupk/OCPyYusHtNM/yrBeHfOJUStwF1 8ZKVyYucexs5RD7oNJbDI4rgq4476sXENSyaWShYuU0yjo4tbmxUNy7HcATi9PZ0Al6X k8ng7g38oYzmKSeAilCJPAUkhjDroFHLPn0qAuSp3lJE8wEEGOFJcjDi9x5FwIS19WV9 /3cOQOu1Ry+l3FckstQLm0+usWCFekkw409Pgn8Gj1bdM13Rlv+ZzMvdLmvx4sL1X/up xoOAmg4jOn5ft7fYYmxoCXskb45k3GYGvx7781SJakr8g8IcThMWfHQ2ZMaVMROOqXJB BpVg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of m.salvini@koansoftware.com designates 172.104.12.216 as permitted sender) smtp.mailfrom=m.salvini@koansoftware.com Received: from mail.koansoftware.com (mail.koansoftware.com. [172.104.12.216]) by gmr-mx.google.com with ESMTPS id l5-20020a0cee25000000b006815ec1421csi318431qvs.7.2024.01.16.03.18.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 03:18:19 -0800 (PST) Received-SPF: pass (google.com: domain of m.salvini@koansoftware.com designates 172.104.12.216 as permitted sender) client-ip=172.104.12.216; Received: from localhost (localhost [127.0.0.1]) by mail.koansoftware.com (Postfix) with ESMTP id BB8BF3C832; Tue, 16 Jan 2024 12:18:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail Received: from mail.koansoftware.com ([127.0.0.1]) by localhost (mail.koansoftware.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CjgInz8RnaKl; Tue, 16 Jan 2024 12:18:17 +0100 (CET) From: Mauro Salvini To: swupdate@googlegroups.com Cc: Mauro Salvini Subject: [swupdate] [PATCH] handlers: raw_handler.c: fix return value when an error occurred Date: Tue, 16 Jan 2024 12:17:05 +0100 Message-Id: <20240116111705.13088-1-m.salvini@koansoftware.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Original-Sender: m.salvini@koansoftware.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of m.salvini@koansoftware.com designates 172.104.12.216 as permitted sender) smtp.mailfrom=m.salvini@koansoftware.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Before this commit, if an error occurs during the raw file handling (e.g. no space on device) and there is a mounted device, the error code got overwritten by the swupdate_umount() return value: if swupdate_umount() returned success (0), the update process did not fail as expected. Signed-off-by: Mauro Salvini --- handlers/raw_handler.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/handlers/raw_handler.c b/handlers/raw_handler.c index 979c55f..4e9b3a4 100644 --- a/handlers/raw_handler.c +++ b/handlers/raw_handler.c @@ -153,6 +153,7 @@ static int install_raw_file(struct img_type *img, char tmp_path[255]; int fdout = -1; int ret = -1; + int cleanup_ret; int use_mount = (strlen(img->device) && strlen(img->filesystem)) ? 1 : 0; char* DATADST_DIR = alloca(strlen(get_tmpdir())+strlen(DATADST_DIR_SUFFIX)+1); sprintf(DATADST_DIR, "%s%s", get_tmpdir(), DATADST_DIR_SUFFIX); @@ -244,12 +245,12 @@ cleanup: close(fdout); if (use_mount) { - ret = swupdate_umount(DATADST_DIR); - if (ret) + cleanup_ret = swupdate_umount(DATADST_DIR); + if (cleanup_ret) WARN("Can't unmount path %s: %s", DATADST_DIR, strerror(errno)); } - return ret; + return (ret ? ret : cleanup_ret); } __attribute__((constructor))