From patchwork Tue Nov 7 12:24:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 741876 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1588338wrr; Tue, 7 Nov 2023 04:29:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyADF0DBpO1GSsYfdFIkwr5tlEhFpqR4OauuSlJ4lJZcKunsN0sF5+uoFDKSMORZ5OZKPn X-Received: by 2002:a05:6830:7181:b0:6b9:a926:4a12 with SMTP id el1-20020a056830718100b006b9a9264a12mr41575928otb.28.1699360147191; Tue, 07 Nov 2023 04:29:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699360147; cv=none; d=google.com; s=arc-20160816; b=eKCc4ecF+m2dckKOoEtYlxNsdZaYicMyfIQLEAyrzyFijquNQ2gR+opt9fuSWQMrJ5 mdibyuEW6bwUXdHhBQD4tnTDg19haCGKOSzJxk/LCs1CIb10s72eK/81NYHzjAR8+uoT P67H32IX9llXn8hpOwuUyT62t+tAPyOwa8yPVPQIUy6k1XxINchQeej8Kk853ZdCEBkH 9jckCKG5kA6/hNBiLhqtM9/kQs8OSpx05JUGQZDwopI6NfbxVYNrvREPPN9zjvQXFgaT 2Tn4Qro7tRA1OIINSJhpFJJ3QWpEvYPrZ6tFCEgwVhynpFdhO4m1C23X231neVgC80co 0QcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bPpjDkEUgqCeZLuJ7FjDj9Qp3yXD435hoj9y2GuMgcc=; fh=cNSzr/W9J/4aJpqP86zm6hStvbeVv6h0MRvfoStHJZE=; b=MexQF4Iygt8+hsDVR05puWmRoMvER6oqC5Xxto4ip2kZl0Wzrm8bzol8e8fMzLVoh/ wBToHnzWu6/s/DRArjzYoZwc1oECIm8tK4g+hfQA0U0kJ0T6zSM0pZ9z3CGSl6wBqKID kuU7HMxmJhPVWRzDqRN3fxu5elnYTGXJAIPIbYUSADnvZ7mGDEmVMJ/KfKwEgWAOtkUS hgvybvYJghCp4LUjTfaMjFD8G5AfezeBe98mBFZh9n1ri7QCstzPGOu9/INuvTqvWKxZ hZsvPjfaRCwnO9iK/s8A3OadDf/g2C8ulpLbQDw/Q+HfFlfBS9BuhS6K7mkdZXYMNDTP GIQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8aVhrGf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u5-20020a05622a198500b0041b83912a5dsi6879827qtc.187.2023.11.07.04.29.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2023 04:29:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8aVhrGf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0LB4-0001en-FN; Tue, 07 Nov 2023 07:27:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0LAH-0007aq-Nq for qemu-devel@nongnu.org; Tue, 07 Nov 2023 07:26:44 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0LA2-0005N7-A5 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 07:26:39 -0500 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-53dfc28a2afso9445149a12.1 for ; Tue, 07 Nov 2023 04:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699359984; x=1699964784; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bPpjDkEUgqCeZLuJ7FjDj9Qp3yXD435hoj9y2GuMgcc=; b=V8aVhrGfgx39OX1v0S1sItKfH5CUDLVzn0sRdn0Le/D38biCGkycCpMb1mGGL5NEg/ 5hJy/iSYiZVA4VLXqUtwGxUn7QiWluaxymKt1UkSrKt5AC3ht1d+iz6wSBgNlW0OQn2v T61Sp+sDtY/GQqLY3PwS95Qhieh68QQPbNCocZbKr+amSADpd+dyFCaZFR5WdzDaoWNe t6EDSKLpLpEhZse9+vORYZUS4ee3/j9oRLszc9q9p9qxmB/a8aVi7Hqw3vQWOMDawGU9 IRXOHOuQiyv+iUxcmZxGe9VQtsxt2yJcH5rtVic11Wz5mFwge0euJwkExdS15oUG6l5W cu3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699359984; x=1699964784; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bPpjDkEUgqCeZLuJ7FjDj9Qp3yXD435hoj9y2GuMgcc=; b=q0XE8n5tLAhpt8e0Q8AWs1adNff8ZOMb+uHHWgIHrwikuW/VWahIF6rojcfj5/+GzG IlCmQOGGPsYh3NCZzCHHnxm5sr0jXIudaeTqB/nKTBO8lNHoRXj0TuAP1AFfMbclVMWD WX0f2VoeKPG7wR24iZprMeWGhuEUwyKZtTx1OiWb3nAhaJ29w2MnNSpUqaJszFPqTILk LcH/lxG1CSOIF8wRiYw0uFyFMn2ddu5B5jhmoc9zIOd0ptcxAoXzN9HN2LZKoux+KFNG NATIJ8S7jSR+lUmnM/G9ehcUIFe+q9Om3E0WRMwqqarByvwdNVIuFRwEu2Wjxv+gT6o4 qs0Q== X-Gm-Message-State: AOJu0YxLMLXqeudQz2coDRKPUGrCaiYccqXwfyydKOZ3KYcc68XmVaSR USaoZugxjbb4uIp8BcxyolnqU7iOjubVCTC+D6U= X-Received: by 2002:a17:907:31c3:b0:9c7:db3:8b31 with SMTP id xf3-20020a17090731c300b009c70db38b31mr19724449ejb.59.1699359983864; Tue, 07 Nov 2023 04:26:23 -0800 (PST) Received: from m1x-phil.lan ([176.187.216.69]) by smtp.gmail.com with ESMTPSA id gz21-20020a170906f2d500b009ddcf5b07b8sm1002418ejb.148.2023.11.07.04.26.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Nov 2023 04:26:23 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Zongmin Zhou , Zongmin Zhou , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 75/75] dump: Add close fd on error return to avoid resource leak Date: Tue, 7 Nov 2023 13:24:41 +0100 Message-ID: <20231107122442.58674-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231107122442.58674-1-philmd@linaro.org> References: <20231107122442.58674-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=philmd@linaro.org; helo=mail-ed1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Zongmin Zhou Reported-by: Coverity CID 1523842 (RESOURCE_LEAK) Fixes: e6549197f7 ("dump: Add command interface for kdump-raw formats") Signed-off-by: Zongmin Zhou Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20231107024417.585475-1-min_halo@163.com> Signed-off-by: Philippe Mathieu-Daudé --- dump/dump.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dump/dump.c b/dump/dump.c index 1c304cadfd..ad5294e853 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -2160,6 +2160,7 @@ void qmp_dump_guest_memory(bool paging, const char *protocol, return; } if (kdump_raw && lseek(fd, 0, SEEK_CUR) == (off_t) -1) { + close(fd); error_setg(errp, "kdump-raw formats require a seekable file"); return; }