All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
@ 2015-03-12 14:57 Paolo Bonzini
  2015-03-12 16:42 ` Eric Blake
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Paolo Bonzini @ 2015-03-12 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
command add_fd).  Free it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 vl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index eba5d4c..8902435 100644
--- a/vl.c
+++ b/vl.c
@@ -1011,6 +1011,7 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
     int fd, dupfd, flags;
     int64_t fdset_id;
     const char *fd_opaque = NULL;
+    AddfdInfo *fdinfo;
 
     fd = qemu_opt_get_number(opts, "fd", -1);
     fdset_id = qemu_opt_get_number(opts, "set", -1);
@@ -1060,8 +1061,9 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
     }
 
     /* add the duplicate fd, and optionally the opaque string, to the fd set */
-    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
-                         fd_opaque, NULL);
+    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
+                                  fd_opaque, NULL);
+    g_free(fdinfo);
 
     return 0;
 }
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-12 14:57 [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd Paolo Bonzini
@ 2015-03-12 16:42 ` Eric Blake
  2015-03-12 23:37 ` Fam Zheng
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Eric Blake @ 2015-03-12 16:42 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial

[-- Attachment #1: Type: text/plain, Size: 440 bytes --]

On 03/12/2015 08:57 AM, Paolo Bonzini wrote:
> monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
> command add_fd).  Free it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  vl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-12 14:57 [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd Paolo Bonzini
  2015-03-12 16:42 ` Eric Blake
@ 2015-03-12 23:37 ` Fam Zheng
  2015-03-13  3:45 ` Patchew Tool
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Fam Zheng @ 2015-03-12 23:37 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-trivial, qemu-devel

On Thu, 03/12 15:57, Paolo Bonzini wrote:
> monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
> command add_fd).  Free it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  vl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index eba5d4c..8902435 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1011,6 +1011,7 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>      int fd, dupfd, flags;
>      int64_t fdset_id;
>      const char *fd_opaque = NULL;
> +    AddfdInfo *fdinfo;
>  
>      fd = qemu_opt_get_number(opts, "fd", -1);
>      fdset_id = qemu_opt_get_number(opts, "set", -1);
> @@ -1060,8 +1061,9 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>      }
>  
>      /* add the duplicate fd, and optionally the opaque string, to the fd set */
> -    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
> -                         fd_opaque, NULL);
> +    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,

Too long a line, with that fixed,

Reviewed-by: Fam Zheng <famz@redhat.com>

> +                                  fd_opaque, NULL);
> +    g_free(fdinfo);
>  
>      return 0;
>  }
> -- 
> 2.3.0
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-12 14:57 [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd Paolo Bonzini
  2015-03-12 16:42 ` Eric Blake
  2015-03-12 23:37 ` Fam Zheng
@ 2015-03-13  3:45 ` Patchew Tool
  2015-03-13  5:17 ` Shannon Zhao
  2015-03-19  8:22 ` Michael Tokarev
  4 siblings, 0 replies; 11+ messages in thread
From: Patchew Tool @ 2015-03-13  3:45 UTC (permalink / raw)
  To: qemu-devel


This series passed Patchew automatic testing, but there are some warnings.

Find the log fragments below, or open the following URL to see the full log:

http://qemu.patchew.org/testing/log/<1426172243-7830-1-git-send-email-pbonzini@redhat.com>

----------8<---------


=== Starting docker ===

Copying test script "/home/patchew/tests/qemu-devel.sh"
Starting docker...
docker run --net=none -v /var/tmp/patchew-tester/tmpELr8N5:/var/tmp/patchew-test patchew:fedora-20 timeout 3600 /var/tmp/patchew-test/qemu-devel.sh /var/tmp/patchew-test

*** Testing 'coding style check' ***

Checking 0001-vl--fix-resource-leak-with-monitor_fdset_add_fd.patch
command failed with exit code 0
$@
WARNING: line over 80 characters
#27: FILE: vl.c:1064:
+    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,

total: 0 errors, 1 warnings, 18 lines checked

0001-vl--fix-resource-leak-with-monitor_fdset_add_fd.patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.


*** Testing 'configure' ***

Install prefix    /usr/local
BIOS directory    /usr/local/share/qemu
binary directory  /usr/local/bin
library directory /usr/local/lib
module directory  /usr/local/lib/qemu
libexec directory /usr/local/libexec

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-12 14:57 [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd Paolo Bonzini
                   ` (2 preceding siblings ...)
  2015-03-13  3:45 ` Patchew Tool
@ 2015-03-13  5:17 ` Shannon Zhao
  2015-03-13 12:53   ` Paolo Bonzini
  2015-03-19  8:22 ` Michael Tokarev
  4 siblings, 1 reply; 11+ messages in thread
From: Shannon Zhao @ 2015-03-13  5:17 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel
  Cc: qemu-trivial, Hangaohuai, Gonglei (Arei), Huangpeng (Peter)

On 2015/3/12 22:57, Paolo Bonzini wrote:
> monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
> command add_fd).  Free it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  vl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index eba5d4c..8902435 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1011,6 +1011,7 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>      int fd, dupfd, flags;
>      int64_t fdset_id;
>      const char *fd_opaque = NULL;
> +    AddfdInfo *fdinfo;
>  
>      fd = qemu_opt_get_number(opts, "fd", -1);
>      fdset_id = qemu_opt_get_number(opts, "set", -1);
> @@ -1060,8 +1061,9 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>      }
>  
>      /* add the duplicate fd, and optionally the opaque string, to the fd set */
> -    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
> -                         fd_opaque, NULL);
> +    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
> +                                  fd_opaque, NULL);
> +    g_free(fdinfo);
>  
>      return 0;
>  }
> 

Hi Paolo,

Not about the resource leak, but I think we should check fdinfo == NULL and return -1.
Then when error occurs, qemu will exit. Besides we should pass a meaningful errp not NULL.
So qemu can report the error reason. Right?

-- 
Thanks,
Shannon

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-13  5:17 ` Shannon Zhao
@ 2015-03-13 12:53   ` Paolo Bonzini
  0 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2015-03-13 12:53 UTC (permalink / raw)
  To: Shannon Zhao, qemu-devel
  Cc: qemu-trivial, Hangaohuai, Gonglei (Arei), Huangpeng (Peter)



On 13/03/2015 06:17, Shannon Zhao wrote:
>> > -    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
>> > -                         fd_opaque, NULL);
>> > +    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
>> > +                                  fd_opaque, NULL);
>> > +    g_free(fdinfo);
>> >  
>> >      return 0;
>> >  }
>> > 
> Hi Paolo,
> 
> Not about the resource leak, but I think we should check fdinfo == NULL and return -1.
> Then when error occurs, qemu will exit. Besides we should pass a meaningful errp not NULL.
> So qemu can report the error reason. Right?

It cannot fail here, so another possibility could be to pass &error_abort.

Paolo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-12 14:57 [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd Paolo Bonzini
                   ` (3 preceding siblings ...)
  2015-03-13  5:17 ` Shannon Zhao
@ 2015-03-19  8:22 ` Michael Tokarev
  4 siblings, 0 replies; 11+ messages in thread
From: Michael Tokarev @ 2015-03-19  8:22 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial

12.03.2015 17:57, Paolo Bonzini wrote:
> monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
> command add_fd).  Free it.

Applied to -trivial, with a tiny change:

> +    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
> +                                  fd_opaque, NULL);

    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id,
                                  fd_opaque ? true : false, fd_opaque, NULL);

(this fits in 80 chars a line).  Another variant is to use `fd_opaque != NULL' here
instead of this ?true:false construct.

Thanks,

/mjt

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-13 13:56 ` Eric Blake
@ 2015-03-14  8:08   ` Markus Armbruster
  0 siblings, 0 replies; 11+ messages in thread
From: Markus Armbruster @ 2015-03-14  8:08 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-trivial, Paolo Bonzini, famz, qemu-devel, zhaoshenglong

Eric Blake <eblake@redhat.com> writes:

> On 03/13/2015 06:55 AM, Paolo Bonzini wrote:
>> monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
>> command add_fd).  Free it.
>> 
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> 	v1->v2: line length [Fam], pass &error_abort [Shannon]
>> ---
>>  vl.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
>> diff --git a/vl.c b/vl.c
>> index eba5d4c..9eae8f9 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -1011,6 +1011,7 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>>      int fd, dupfd, flags;
>>      int64_t fdset_id;
>>      const char *fd_opaque = NULL;
>> +    AddfdInfo *fdinfo;
>>  
>>      fd = qemu_opt_get_number(opts, "fd", -1);
>>      fdset_id = qemu_opt_get_number(opts, "set", -1);
>> @@ -1060,8 +1061,10 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>>      }
>>  
>>      /* add the duplicate fd, and optionally the opaque string, to
>> the fd set */
>> -    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
>> -                         fd_opaque, NULL);
>> +    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id,
>> +                                  fd_opaque ? true : false, fd_opaque,
>
> I might have written !!fd_opaque (as cond ? true : false always looks so
> long), but that's cosmetic and doesn't affect the review.

The use of ?: here borders on code obfuscation.  Please clean it up.

If you can't stand !!fd_opaque, then use fd_opaque != NULL.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-13 12:55 Paolo Bonzini
  2015-03-13 13:56 ` Eric Blake
@ 2015-03-14  1:15 ` Shannon Zhao
  1 sibling, 0 replies; 11+ messages in thread
From: Shannon Zhao @ 2015-03-14  1:15 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial, famz, Huangpeng (Peter)

On 2015/3/13 20:55, Paolo Bonzini wrote:
> monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
> command add_fd).  Free it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 	v1->v2: line length [Fam], pass &error_abort [Shannon]
> ---
>  vl.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 

Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>

> diff --git a/vl.c b/vl.c
> index eba5d4c..9eae8f9 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1011,6 +1011,7 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>      int fd, dupfd, flags;
>      int64_t fdset_id;
>      const char *fd_opaque = NULL;
> +    AddfdInfo *fdinfo;
>  
>      fd = qemu_opt_get_number(opts, "fd", -1);
>      fdset_id = qemu_opt_get_number(opts, "set", -1);
> @@ -1060,8 +1061,10 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>      }
>  
>      /* add the duplicate fd, and optionally the opaque string, to the fd set */
> -    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
> -                         fd_opaque, NULL);
> +    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id,
> +                                  fd_opaque ? true : false, fd_opaque,
> +                                  &error_abort);
> +    g_free(fdinfo);
>  
>      return 0;
>  }
> 


-- 
Thanks,
Shannon

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
  2015-03-13 12:55 Paolo Bonzini
@ 2015-03-13 13:56 ` Eric Blake
  2015-03-14  8:08   ` Markus Armbruster
  2015-03-14  1:15 ` Shannon Zhao
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Blake @ 2015-03-13 13:56 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-trivial, famz, zhaoshenglong

[-- Attachment #1: Type: text/plain, Size: 1491 bytes --]

On 03/13/2015 06:55 AM, Paolo Bonzini wrote:
> monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
> command add_fd).  Free it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 	v1->v2: line length [Fam], pass &error_abort [Shannon]
> ---
>  vl.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

> diff --git a/vl.c b/vl.c
> index eba5d4c..9eae8f9 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1011,6 +1011,7 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>      int fd, dupfd, flags;
>      int64_t fdset_id;
>      const char *fd_opaque = NULL;
> +    AddfdInfo *fdinfo;
>  
>      fd = qemu_opt_get_number(opts, "fd", -1);
>      fdset_id = qemu_opt_get_number(opts, "set", -1);
> @@ -1060,8 +1061,10 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
>      }
>  
>      /* add the duplicate fd, and optionally the opaque string, to the fd set */
> -    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
> -                         fd_opaque, NULL);
> +    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id,
> +                                  fd_opaque ? true : false, fd_opaque,

I might have written !!fd_opaque (as cond ? true : false always looks so
long), but that's cosmetic and doesn't affect the review.


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
@ 2015-03-13 12:55 Paolo Bonzini
  2015-03-13 13:56 ` Eric Blake
  2015-03-14  1:15 ` Shannon Zhao
  0 siblings, 2 replies; 11+ messages in thread
From: Paolo Bonzini @ 2015-03-13 12:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, famz, zhaoshenglong

monitor_fdset_add_fd returns an AddfdInfo struct (used by the QMP
command add_fd).  Free it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
	v1->v2: line length [Fam], pass &error_abort [Shannon]
---
 vl.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index eba5d4c..9eae8f9 100644
--- a/vl.c
+++ b/vl.c
@@ -1011,6 +1011,7 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
     int fd, dupfd, flags;
     int64_t fdset_id;
     const char *fd_opaque = NULL;
+    AddfdInfo *fdinfo;
 
     fd = qemu_opt_get_number(opts, "fd", -1);
     fdset_id = qemu_opt_get_number(opts, "set", -1);
@@ -1060,8 +1061,10 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
     }
 
     /* add the duplicate fd, and optionally the opaque string, to the fd set */
-    monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
-                         fd_opaque, NULL);
+    fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id,
+                                  fd_opaque ? true : false, fd_opaque,
+                                  &error_abort);
+    g_free(fdinfo);
 
     return 0;
 }
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-03-19  8:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 14:57 [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd Paolo Bonzini
2015-03-12 16:42 ` Eric Blake
2015-03-12 23:37 ` Fam Zheng
2015-03-13  3:45 ` Patchew Tool
2015-03-13  5:17 ` Shannon Zhao
2015-03-13 12:53   ` Paolo Bonzini
2015-03-19  8:22 ` Michael Tokarev
2015-03-13 12:55 Paolo Bonzini
2015-03-13 13:56 ` Eric Blake
2015-03-14  8:08   ` Markus Armbruster
2015-03-14  1:15 ` Shannon Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.