From nobody Tue May 7 15:04:49 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 1488564272151166.4653034125945; Fri, 3 Mar 2017 10:04:32 -0800 (PST) Received: from localhost ([::1]:59484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjrZ8-0002AD-Mf for importer@patchew.org; Fri, 03 Mar 2017 13:04:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjrYc-0002A7-Bf for qemu-devel@nongnu.org; Fri, 03 Mar 2017 13:03:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjrYX-0003mT-CJ for qemu-devel@nongnu.org; Fri, 03 Mar 2017 13:03:58 -0500 Received: from 8.mo173.mail-out.ovh.net ([46.105.46.122]:44423) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cjrYX-0003mC-77 for qemu-devel@nongnu.org; Fri, 03 Mar 2017 13:03:53 -0500 Received: from player726.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 3E9E82A166 for ; Fri, 3 Mar 2017 19:03:51 +0100 (CET) Received: from bahia.lan (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 CD2072A007F; Fri, 3 Mar 2017 19:03:47 +0100 (CET) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 03 Mar 2017 19:03:47 +0100 Message-ID: <148856422757.9841.6298006998523421948.stgit@bahia.lan> 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: 12684106876183878025 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelhedrfeeggddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.46.122 Subject: [Qemu-devel] [PATCH] 9pfs: fail local_statfs() earlier 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 If we cannot open the given path, we can return right away instead of passing -1 to fstatfs() and close(). This will make Coverity happy. (Coverity issue CID1371729) Signed-off-by: Greg Kurz Reviewed-by: Daniel P. berrange Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/9pfs/9p-local.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index fe930300445a..ea9a1ced0394 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1053,6 +1053,9 @@ static int local_statfs(FsContext *s, V9fsPath *fs_pa= th, struct statfs *stbuf) int fd, ret; =20 fd =3D local_open_nofollow(s, fs_path->data, O_RDONLY, 0); + if (fd =3D=3D -1) { + return -1; + } ret =3D fstatfs(fd, stbuf); close_preserve_errno(fd); return ret;