Skip to contentSkip to conversation

9pfs: fix fd leak in local_opendir()

PATCH In review Greg Kurz 3 participants 3 messages Mar 3, 2017

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 9pfs: fix fd leak in local_opendir()

Coverity issue CID1371731

---
 hw/9pfs/9p-local.c |    1 +
 1 file changed, 1 insertion(+)
hw/9pfs/9p-local.c +1 -0
index e31309a29c58..fe930300445a 100644
@@ -435,6 +435,7 @@ static int local_opendir(FsContext *ctx,
 
     stream = fdopendir(dirfd);
     if (!stream) {
+        close(dirfd);
         return -1;
     }
     fs->dir.stream = stream;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Greg Kurz

Coverity issue CID1371731

---
 hw/9pfs/9p-local.c |    1 +
 1 file changed, 1 insertion(+)
hw/9pfs/9p-local.c +0 -0
index e31309a29c58..fe930300445a 100644

hw/9pfs/9p-local.c static int local_opendir(FsContext *ctx, · line 441

Quoted 7 lines
hw/9pfs/9p-local.c +1 -0
@@ -435,6 +435,7 @@ static int local_opendir(FsContext *ctx,
 
     stream = fdopendir(dirfd);
     if (!stream) {
+        close(dirfd);
         return -1;
     }
     fs->dir.stream = stream;

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
#2 lore raw
Quoted 23 lines · Daniel P. Berrange
Quoted 12 lines · Greg Kurz

Coverity issue CID1371731

---
 hw/9pfs/9p-local.c |    1 +
 1 file changed, 1 insertion(+)
hw/9pfs/9p-local.c +0 -0
index e31309a29c58..fe930300445a 100644

hw/9pfs/9p-local.c static int local_opendir(FsContext *ctx, · line 441

Quoted 7 lines
hw/9pfs/9p-local.c +1 -0
@@ -435,6 +435,7 @@ static int local_opendir(FsContext *ctx,
 
     stream = fdopendir(dirfd);
     if (!stream) {
+        close(dirfd);
         return -1;
     }
     fs->dir.stream = stream;
Quoted 3 lines

Regards,
Daniel