Message ID | 20210724150714.567177-1-festevam@gmail.com |
---|---|
State | Accepted |
Headers | show
Return-Path: <swupdate+bncBDULZYNR2QMRBLGZ6CDQMGQED5PQMUQ@googlegroups.com> 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::739; helo=mail-qk1-x739.google.com; envelope-from=swupdate+bncbdulzynr2qmrblgz6cdqmgqed5pqmuq@googlegroups.com; receiver=<UNKNOWN>) 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=YAQpSWkZ; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=bEEWP0/g; dkim-atps=neutral Received: from mail-qk1-x739.google.com (mail-qk1-x739.google.com [IPv6:2607:f8b0:4864:20::739]) (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 4GX8gN0MnFz9sX1 for <incoming@patchwork.ozlabs.org>; Sun, 25 Jul 2021 01:07:27 +1000 (AEST) Received: by mail-qk1-x739.google.com with SMTP id t191-20020a37aac80000b02903b9402486c5sf3946834qke.13 for <incoming@patchwork.ozlabs.org>; Sat, 24 Jul 2021 08:07:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1627139244; cv=pass; d=google.com; s=arc-20160816; b=F2COSzhyYkE2nV3hA2oL0Pimr3ZhoXLiER3FsRifDKhS8WmxPUWea9A5D8hdf3OgGM lLHvPa94pVPLwnlr/u832Ix95X3ErjaUe3ii+C47//fHDabt1NPri9Ai8wYYQsoVDpsc Q2gJ6xvkaotRgNS0cAbkWNuyXl5G+kRvB3+1UzaEnu7wqgts1sCoFpKKWTYVt+81nYvg ZYUQUu9zH3mzuQ7Ux13Qonc5Qp89XtkIwX7gaKt5DGQPx+lftpijBmtamDFGjWRJIbRg WaMmVOqcaV9ZEEhpW+LOE9m3LOCo1VZvXzlMI9MmMTbWylXsMryhJC6YwgsvVloVyJMG lmNQ== 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=mpJAgAtRajrp/LONXyKhEi3MPqvXBSj0gfuHk060JRA=; b=pynqpvnj4AmxmO6fg3AN5x+WauxBEB7n0+G9EgyJZD1cFRj/LfnUR6tus4DJsyM/Qe 3wgdhD90nyklHB7Ceak1DP+SKW+7GZTHiiuB/4Pb851gt+NaJw8Rblhi5HE4K6uSphD2 Q+DuOBUA5CAI8CscSUoCOtrQ+aORWDadgH6lESc6Dvi/iArB8I1cQ0er7FT6xrugfLId 99Z6cANsy/aN2tiPqO8zcORDXelunKD3snIE/uIj9e/PXyq4cNLlj3UtuGHMc7gwiJvd 0vjo0oNO46Vr2n4GYfcwz4AVDwFx6AGVkwiOpW3jSuDziHCqFrJCMkctf53A9AyaVA2g mQBw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GKyquQtt; spf=pass (google.com: domain of festevam@gmail.com designates 2607:f8b0:4864:20::1032 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=mpJAgAtRajrp/LONXyKhEi3MPqvXBSj0gfuHk060JRA=; b=YAQpSWkZDxQ6MPRgCJ8Jclqi6RBBlc9m3SIItgcgvEH9axpUVqikhyE8EXHIhDQfOa pKrMy7nlqyQEElcnVQ+cy+02DJmNNmeKOhqhACAbzEscezr1TFnrSUuvWqVyjLHdSg3f QBL7NonqdoOEMFEf5A3w67eJpprnBTbxqNN5iZvU1ARQbr897HcBzviCR8aW3aQ1rYRo xFc4VjqiBbzgQlRB2Tqoo+lYOEbeWvmYxCtkQBVLnJqsOUIRANy6to3Vktclb8UT5xFp KRCt4uVrYAzzCLD55m/l75sua0tkkN1JhT9PbF2VRr1DD/HzDjcQ/Af+A0SBBf3j2dJl zxSw== 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=mpJAgAtRajrp/LONXyKhEi3MPqvXBSj0gfuHk060JRA=; b=bEEWP0/gKz0FPktZ5c4VZGvhxljOu7kJWEmhi/XZHQpEyUyxdB1ek7fffjT0U3/7T2 xibZsI31SlwJz6w/xCVDBoNy2wkLBwO6Pg2N8bYw1xBBofQkxNrPSeBRKIU49fVqn6xd n90VK0gGY7+OyLTiVSXMrZ9H15qEuPEPsP4m5C28QIzd9WL05Wfx6i2nd5zcvMLb0HTi HWG1Zoo0raafctSmZnfcFz7Wn379Kq1T1Jm0qfSQSM0PFJ4F6CPfraksNumeVyUOEWOA BV/BGagJdTKPrL1onwWMxY5WEB2xwnLVGgFaHicX9Dvs9BPtzSwubRiLU2P7NURo0uo3 1qcg== 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=mpJAgAtRajrp/LONXyKhEi3MPqvXBSj0gfuHk060JRA=; b=TrLacGc3QqEcXPAJyb+x9vNtzAsEdAuLjyhnysetsHexG3mO7sA1oYPjrdrlyQBlf7 +uTk4Y+E8eEcaqasPjH34QAcRExiT2Auan+Vv88FJ1TBFQ5Jn5ykRuKfl3aiqzjtupTg EdvlhyVVSkEIBS+T/nfXGdz3MWM4eAdTGiyoiWgtv3mUpgxefMaEK4Hs0VDDlIe2nh5D jKzw3P1q2fyUovXaFYOWfqfHrlyE2XEw6tqd9rrRy7Y41HMc1JA5bs0m/mxjh/Pt15qm URzFLicu376bBKAakjvYM+S2trHT3LRd4kHuxbeaKVbuw0HCfcnr4wWL/t5/4k0GPmJg o+Lw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532afHaNCW1HlOzkZxxrrKNZSH90uC2rdZievXOCKD7LGfnv+F4e QZwC6jOxYMK0FD8wfyE40mA= X-Google-Smtp-Source: ABdhPJxSBM6llufyaLBFfvBtiBgMhJQwRLqjGmEe9/Psjse6CmIiE6UIBz/rEpo2bjn3Yk7uwvO0uQ== X-Received: by 2002:a37:e302:: with SMTP id y2mr9802070qki.401.1627139244603; Sat, 24 Jul 2021 08:07:24 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:ac8:b08:: with SMTP id e8ls6204365qti.3.gmail; Sat, 24 Jul 2021 08:07:24 -0700 (PDT) X-Received: by 2002:ac8:548a:: with SMTP id h10mr8156727qtq.89.1627139244207; Sat, 24 Jul 2021 08:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627139244; cv=none; d=google.com; s=arc-20160816; b=LO5ls4t1zM1PY3ifiyzA3a8ao+ej9FXdXOMWpzIAhVK1pc9PkDdNXiLDecTXRG4zTD gutGO6PoaX4VR3hbUKt8Ba1RwHZVtBjmK72i38Lw9EhMoSN1mcQFsLxc5JpvIEk3fGkj VxmZhIOo8fYLnGVz/qjJ+79dE4Lbhg3z0CTwpxnvJ08w36doBcxSqj8Oz930YJGD1AxY YZfgdVL60bbluJVJ8dDKQxfoeoox2TToR9Y0lLkkizYq7d+g0hs+XK1bR1niDdVB/4JL sOJMfqFksTZSJJ86yNYE9K2vkDg3BRlg3UrLsdW+7ymYfvPT6EtRrUuuFI5AhEJ1MjVv uTlA== 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=VwqNpR6N7B/N2+MjZHdVG8f1jOkEq8uOhkbjIubBAQ1ycA6vGEtuVh1t8GvGCtUk5q NMtm07pA30Xfx/ZMjDbfhTA+6yfVvk8UuLhao4oCp+F9XL6NbTIXO9ggc9OBcLYGJ7Ar rmFFFyaD+TYdCHZK0PmsKmjCD/trwCPgODrdz2HJWaAB+xJiLKnNEYB7qwV5x9brSuTt KJ6UZTbPkC+JnL0GDS8H4vipAXm/Eciq1vAjhZGSV/P0Bk76M/INFv5Gf4q+rGFmGP3f Q0yHwMhOOB/Si9J6xRXIHzp552MqZnBuNxDuZZNtxqT3gtShhyhKgGIs0zHAyzf+ztpJ PcDQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GKyquQtt; spf=pass (google.com: domain of festevam@gmail.com designates 2607:f8b0:4864:20::1032 as permitted sender) smtp.mailfrom=festevam@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com. [2607:f8b0:4864:20::1032]) by gmr-mx.google.com with ESMTPS id x14si338813qkp.6.2021.07.24.08.07.24 for <swupdate@googlegroups.com> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Jul 2021 08:07:24 -0700 (PDT) Received-SPF: pass (google.com: domain of festevam@gmail.com designates 2607:f8b0:4864:20::1032 as permitted sender) client-ip=2607:f8b0:4864:20::1032; Received: by mail-pj1-x1032.google.com with SMTP id g23-20020a17090a5797b02901765d605e14so7817457pji.5 for <swupdate@googlegroups.com>; Sat, 24 Jul 2021 08:07:24 -0700 (PDT) X-Received: by 2002:a63:1d41:: with SMTP id d1mr9903922pgm.199.1627139243101; Sat, 24 Jul 2021 08:07:23 -0700 (PDT) Received: from localhost.localdomain ([2804:431:d77f:26f1:1bce:1fc6:1476:4c5f]) by smtp.gmail.com with ESMTPSA id u16sm41783477pgh.53.2021.07.24.08.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 08:07:22 -0700 (PDT) From: Fabio Estevam <festevam@gmail.com> To: swupdate@googlegroups.com Cc: sbabic@denx.de, Fabio Estevam <festevam@gmail.com> Subject: [swupdate] [PATCH 1/3] stream_interface: Close the file descriptor on failure Date: Sat, 24 Jul 2021 12:07:12 -0300 Message-Id: <20210724150714.567177-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=GKyquQtt; spf=pass (google.com: domain of festevam@gmail.com designates 2607:f8b0:4864:20::1032 as permitted sender) smtp.mailfrom=festevam@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: <swupdate.googlegroups.com> X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: <https://groups.google.com/group/swupdate/post>, <mailto:swupdate@googlegroups.com> List-Help: <https://groups.google.com/support/>, <mailto:swupdate+help@googlegroups.com> List-Archive: <https://groups.google.com/group/swupdate List-Subscribe: <https://groups.google.com/group/swupdate/subscribe>, <mailto:swupdate+subscribe@googlegroups.com> List-Unsubscribe: <mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>, <https://groups.google.com/group/swupdate/subscribe> |
Series |
[1/3] stream_interface: Close the file descriptor on failure
|
expand
|
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;
When img_check_free_space() fails the previously acquired file descriptor should be closed. Signed-off-by: Fabio Estevam <festevam@gmail.com> --- core/stream_interface.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)