9pfs: fix bogus fd check in local_remove()
authorGreg Kurz <groug@kaod.org>
Mon, 6 Mar 2017 16:34:01 +0000 (17:34 +0100)
committerGreg Kurz <groug@kaod.org>
Mon, 6 Mar 2017 16:34:01 +0000 (17:34 +0100)
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>
hw/9pfs/9p-local.c

index f22a3c3654db63b650d6191b90735a9029c35a84..5db7104334d6b60a033f0573243d67481ffc0b8f 100644 (file)
@@ -1008,7 +1008,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;
     }