[Qemu-devel] [PATCH] 9pfs: fix fd leak in local_opendir()

Greg Kurz posted 1 patch 7 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/148856356236.7604.4296371092878661257.stgit@bahia.lan
Test checkpatch passed
Test docker passed
hw/9pfs/9p-local.c |    1 +
1 file changed, 1 insertion(+)
[Qemu-devel] [PATCH] 9pfs: fix fd leak in local_opendir()
Posted by Greg Kurz 7 years, 1 month ago
Coverity issue CID1371731

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/9p-local.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index e31309a29c58..fe930300445a 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -435,6 +435,7 @@ static int local_opendir(FsContext *ctx,
 
     stream = fdopendir(dirfd);
     if (!stream) {
+        close(dirfd);
         return -1;
     }
     fs->dir.stream = stream;


Re: [Qemu-devel] [PATCH] 9pfs: fix fd leak in local_opendir()
Posted by Daniel P. Berrange 7 years, 1 month ago
On Fri, Mar 03, 2017 at 06:52:42PM +0100, Greg Kurz wrote:
> Coverity issue CID1371731
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>  hw/9pfs/9p-local.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index e31309a29c58..fe930300445a 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -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: Daniel P. Berrange <berrange@redhat.com>

Regards,
Daniel
-- 
|: 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/ :|

Re: [Qemu-devel] [PATCH] 9pfs: fix fd leak in local_opendir()
Posted by Philippe Mathieu-Daudé 7 years, 1 month ago
On 03/03/2017 02:54 PM, Daniel P. Berrange wrote:
> On Fri, Mar 03, 2017 at 06:52:42PM +0100, Greg Kurz wrote:
>> Coverity issue CID1371731
>>
>> Signed-off-by: Greg Kurz <groug@kaod.org>
>> ---
>>  hw/9pfs/9p-local.c |    1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
>> index e31309a29c58..fe930300445a 100644
>> --- a/hw/9pfs/9p-local.c
>> +++ b/hw/9pfs/9p-local.c
>> @@ -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: Daniel P. Berrange <berrange@redhat.com>
>
> Regards,
> Daniel
>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>