]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
9pfs: fix bogus fd check in local_remove()
authorGreg Kurz <groug@kaod.org>
Mon, 6 Mar 2017 16:34:01 +0000 (17:34 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 16 Mar 2017 17:08:41 +0000 (12:08 -0500)
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 <groug@kaod.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit b7361d46e75f12d8d943ca8d33ef82cafce39920)
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/9pfs/9p-local.c

index a87617df1e07a3efbf58530ff0985a934e9be5ac..a50a01f03ba48a972936f6e11d16d99b8dfdc3c4 100644 (file)
@@ -1009,7 +1009,7 @@ static int local_remove(FsContext *ctx, const char *path)
     int err = -1;
 
     dirfd = local_opendir_nofollow(ctx, dirpath);
-    if (dirfd) {
+    if (dirfd == -1) {
         goto out;
     }