From patchwork Sat Jul 24 15:06:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 1509515 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=googlegroups.com (client-ip=2607:f8b0:4864:20::63d; helo=mail-pl1-x63d.google.com; envelope-from=swupdate+bncbdulzynr2qmrb2gy6cdqmgqekhg6jra@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=Ge+zeSa8; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=EWL0cWal; dkim-atps=neutral Received: from mail-pl1-x63d.google.com (mail-pl1-x63d.google.com [IPv6:2607:f8b0:4864:20::63d]) (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 4GX8f62jw6z9sX1 for ; Sun, 25 Jul 2021 01:06:20 +1000 (AEST) Received: by mail-pl1-x63d.google.com with SMTP id k16-20020a170902ba90b029012c06f217cdsf575687pls.14 for ; Sat, 24 Jul 2021 08:06:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1627139177; cv=pass; d=google.com; s=arc-20160816; b=zwDER2Jq+Er0zEb7T/omvlHIeIbVmdwgkFsrjrBEj/P+aB+XFvhlRor5exfQDsl0+F tgwDu1P5fqo8fwcET0xrBOifRuBwv1ZtIxyVhW7xguSFunxtRaO9qVtw8R5O+JwtxqSU gbJITEy7snjNnGzu3uNjhd31i6QLgX/va7zjZRAu4q/W/ujW/4hVvXMo9xBX++E2fg0I fI9byKX4amw7liRYdNSI4FdkkGN691M5NKRKO6k5JK6WL2A92nzAwjoHdr7G8JYu3jWg 27/X8Is0BzO6U39JfI44YZpwflGD9dhrMLni9/EZOL10TMW3Zfp6lzNRJJqGwYRDPlUT ANrA== 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:dkim-signature; bh=4kFsO4VuHE6+x7wg1hq+4+m36NzK+eRpYMxmV8j61eI=; b=FuR+tpajRSOYXX1mEaf0ctcKbyRigy4mRSBEpLHpBkfiRl+8AgsY/Lzijs922v5SQ0 QcK/vGMVzOkXPJCXjBNN8nwwkoiipmGJySmVSCuSnI2+xAhcMAUC9OEpN/dD1wzlykW7 6dmVQ87XhtgqhTk8yHwI4g+FmWuL7Dh/mSGVI6yaPVnhhQMZ0Rsg6N6RDxxkxeJrh5TP 6ZCYk/4L70/PVV0vWz4kX/qS81KTclfsCY0T3jmLCotNcjvSiQaKMLOoljpt/fMPsYhi ZZPErim35O53kcUoNL27JDaQs30FNszZX7TG97Ey6A/Y/IefAbVwYqNpVuAVkB9Z4n2I yvSw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TW7+DUyI; spf=pass (google.com: domain of festevam@gmail.com designates 2607:f8b0:4864:20::102e as permitted sender) smtp.mailfrom=festevam@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=4kFsO4VuHE6+x7wg1hq+4+m36NzK+eRpYMxmV8j61eI=; b=Ge+zeSa8e3s+RlgC4iSGAPrtBJAcoJXeXEsqp6G+gZ+XazWpnddVBDkur5jtvuImY8 ndZ24DbhGFYUgEb2KlRPzi3OZzZKJ+PdOysyPKPiUuTMA++4yCPePgbhrj4MJCS7KNHT 4OlvJNAol3HsMgfXi3JVxpNgGPnPLlmpUl8IAfEGi4N0BxvTSPnprJRqX5b81JJqvE3y iumGL+Cn20SritklBrn69xyeXPhZEQYV/zUO3chOR8U2hnE1n4iJXKtd3TxovB38NcQ1 vce7gYRMrsh0/gKbKaShk68wJbWaJbkIGN8mkEu2NHefT4me134GNhpc+GuBMwI5CdhO USdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=4kFsO4VuHE6+x7wg1hq+4+m36NzK+eRpYMxmV8j61eI=; b=EWL0cWald2t4LoRRcL53M/+cixzzomkbHCqgDCyHI9ZQoPRvgtiB9LCNeEL2iH4AeS WclmjUrfaPHtTUag/8yzX3+vIcP4JchnyRN1O5VneGZktmyo42fO7fL/zb8MZTUhbvfD LYcGJOyk5AMpHATxE9I0RHjO8XyCT3YbsSl9OL9rwoLCDhrrLLpPfxOniaSkC+f7lyFS AmRIcDvmuK3yx3MGztvF47eNwINlh790WkbuY2Hcn+SsMuiGMHqvD91qJ67P9oF/PY7E ahRdYhvdtYcbsY19MKJs9oMWQHWuNeJ1FUG0NbZcst5Rwxf4ejn7zC82vkctoOa463lx 1YbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=4kFsO4VuHE6+x7wg1hq+4+m36NzK+eRpYMxmV8j61eI=; b=orcV/Ri3xerFJf3TBtTzrjAFFrNLllT+PqVAukVX+cKfXWR1sNFaUQ21Qnh6AHWKNM 72GfWhu3xjGQ/9mdg/Y/n2GIrcm4Hg7J7gvtWnuvamF3YXkrxTG3Go4Op8bOqzK7wop5 LIhXN1XRmgjm1Ni3ROTXp00aJOXEsjmjDSYc6N4e9qYV8bDQpLV7H0FMB/ZcGbvStm0s /EXq1FsdzdKAa7mGbFQ7VGRXnuHGSPuHZ8uJTFBwn8j7vhW36NrbQU21UJ85tEypFB70 zXW7D+LON05g8+QdRuskoTorH34SteOMFFlMPG9cdMET114JqaJE5YjnY1q0cnsep99X eDFg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5319SeTIC4JI/GPgh3e/JsNPQA3ja1+4BYvL2aIZv+5aMbPDpP6r DPV0Kl3mYDUmSY61gs9RJ9s= X-Google-Smtp-Source: ABdhPJy8/75CGhvbHVGwsHZbivaAbsTYq6n4IkRuR87rPYCIyzpaot4iAxBWZXepr2z1tj6aPuwlUQ== X-Received: by 2002:a63:443:: with SMTP id 64mr9965838pge.375.1627139177255; Sat, 24 Jul 2021 08:06:17 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:902:7b8c:: with SMTP id w12ls1610932pll.0.gmail; Sat, 24 Jul 2021 08:06:16 -0700 (PDT) X-Received: by 2002:a17:902:8683:b029:12b:67f1:9d1 with SMTP id g3-20020a1709028683b029012b67f109d1mr7839443plo.9.1627139176408; Sat, 24 Jul 2021 08:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627139176; cv=none; d=google.com; s=arc-20160816; b=0W7Cnqn2uNlO4kA6L8LcSTdTGK7waczO+verwFpTR7oZLCfMEajdhlJrGcS+N2uaSQ 0PKCBtVSQOYxRobKJxNJ4oR4aqyZpI8YRGz2tEXjOr0C2IL2qP9HBBeinH7hAbo1a2Fd o32KHdBbkfV2fBnLNcDBU6nIeCQ3da8NcIaKSQlwRvveruQAchlSLojNv0uKUdRXQx8p 3DL9pL00kZf9gZcFKJwyCundtgGopRn1dzqka3ydfCe+U4gKG5/BbNvuXOtYSw3K39lY srMCTidxF824JSPVyBiDoiWHr6ZzuPYWsMvxqFtCHhf66Hx7QrWS6cd4G9h2+Mzcm/6E 1Usg== 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:dkim-signature; bh=o4K+kOHKWOW8cSiCIfc1sHPHYlxZ3uuLwo1CCHWmKsw=; b=c9srgEbZThTy26jhcIk5W3irBShK5f+pgAwUKgotWrZkrMZ9Ps8eDhINQcXUSGuc+K Yp3k/nJ7MQ70slSv9yFCk1Ap9HVKG+SM4W8DuEzhIpeWuoiKjCk+WNmG4j3cNiQW2It9 KChotb3+w/6aoi9CPp9/9T+FXDX987YVI1ecWmdGotnlfgT4109VpQ4/prYppfMC3FR/ xoOE2T5CmBSNSXHv86AmSxjIAGe8AZJQPJyYZkVzjcJhhYhiQpjvZxO/eisy8Hv/5EpM wStqlObBVK08A3JJTbgO+3WT7zfrD7s8q7OWXFtIZ6A4T3m4TCMMvXzdSGb5S1mFKTQ6 bBwQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TW7+DUyI; spf=pass (google.com: domain of festevam@gmail.com designates 2607:f8b0:4864:20::102e as permitted sender) smtp.mailfrom=festevam@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com. [2607:f8b0:4864:20::102e]) by gmr-mx.google.com with ESMTPS id h9si740388pja.1.2021.07.24.08.06.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Jul 2021 08:06:16 -0700 (PDT) Received-SPF: pass (google.com: domain of festevam@gmail.com designates 2607:f8b0:4864:20::102e as permitted sender) client-ip=2607:f8b0:4864:20::102e; Received: by mail-pj1-x102e.google.com with SMTP id m2-20020a17090a71c2b0290175cf22899cso7886084pjs.2 for ; Sat, 24 Jul 2021 08:06:16 -0700 (PDT) X-Received: by 2002:a17:90b:238f:: with SMTP id mr15mr18332552pjb.57.1627139175744; Sat, 24 Jul 2021 08:06:15 -0700 (PDT) Received: from localhost.localdomain ([2804:431:d77f:26f1:1bce:1fc6:1476:4c5f]) by smtp.gmail.com with ESMTPSA id ml9sm4863942pjb.53.2021.07.24.08.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 08:06:15 -0700 (PDT) From: Fabio Estevam To: swupdate@googlegroups.com Cc: sbabic@denx.de, Fabio Estevam Subject: [swupdate] [PATCH 1/3] stream_interface: Close the file descriptor on failure Date: Sat, 24 Jul 2021 12:06:03 -0300 Message-Id: <20210724150605.567038-1-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: festevam@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TW7+DUyI; spf=pass (google.com: domain of festevam@gmail.com designates 2607:f8b0:4864:20::102e as permitted sender) smtp.mailfrom=festevam@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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: , When img_check_free_space() fails the previously acquired file descriptor should be closed. Signed-off-by: Fabio Estevam --- core/stream_interface.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/stream_interface.c b/core/stream_interface.c index efa9cbd64edb..da0c73353e50 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -222,8 +222,10 @@ static int extract_files(int fd, struct swupdate_cfg *software) fdout = openfileoutput(img->extract_file); if (fdout < 0) return -1; - if (!img_check_free_space(img, fdout)) + if (!img_check_free_space(img, fdout)) { + close(fdout); return -1; + } if (copyfile(fd, &fdout, fdh.size, &offset, 0, 0, 0, &checksum, img->sha256, false, NULL, NULL) < 0) { close(fdout); return -1;