From nobody Thu May 2 12:25:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148855791177079.54837552595052; Fri, 3 Mar 2017 08:18:31 -0800 (PST) Received: from localhost ([::1]:58877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjpuX-0007RY-JN for importer@patchew.org; Fri, 03 Mar 2017 11:18:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjptw-0007Q5-Mf for qemu-devel@nongnu.org; Fri, 03 Mar 2017 11:17:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjptt-0006Kd-GV for qemu-devel@nongnu.org; Fri, 03 Mar 2017 11:17:52 -0500 Received: from 7.mo173.mail-out.ovh.net ([46.105.44.159]:42919) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cjptt-0006Ju-9o for qemu-devel@nongnu.org; Fri, 03 Mar 2017 11:17:49 -0500 Received: from player726.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id DABD02A4D0 for ; Fri, 3 Mar 2017 17:17:47 +0100 (CET) Received: from [192.168.66.23] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player726.ha.ovh.net (Postfix) with ESMTPA id 820D12A009A; Fri, 3 Mar 2017 17:17:46 +0100 (CET) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 03 Mar 2017 17:17:40 +0100 Message-ID: <148855786023.23661.6584039229850547004.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 10892800126237841728 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelhedrfeeggdekkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecu X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.44.159 Subject: [Qemu-devel] [PATCH] 9pfs: fix bogus fd check in local_remove() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This was spotted by Coverity as a fd leak. This is certainly true, but also local_remove() would always return without doing anything, unless the fd is zero, which is very unlikely. (Coverity issue CID1371732) Signed-off-by: Greg Kurz Reviewed-by: Eric Blake --- hw/9pfs/9p-local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index f22a3c3654db..5db7104334d6 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1008,7 +1008,7 @@ static int local_remove(FsContext *ctx, const char *p= ath) int err =3D -1; =20 dirfd =3D local_opendir_nofollow(ctx, dirpath); - if (dirfd) { + if (dirfd =3D=3D -1) { goto out; } =20