All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shannon Zhao <zhaoshenglong@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>, <qemu-devel@nongnu.org>
Cc: qemu-trivial@nongnu.org, Hangaohuai <hangaohuai@huawei.com>,
	"Gonglei \(Arei\)" <arei.gonglei@huawei.com>,
	"Huangpeng \(Peter\)" <peter.huangpeng@huawei.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
Date: Fri, 13 Mar 2015 13:17:40 +0800	[thread overview]
Message-ID: <550272F4.30309@huawei.com> (raw)
In-Reply-To: <1426172243-7830-1-git-send-email-pbonzini@redhat.com>

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



WARNING: multiple messages have this Message-ID (diff)
From: Shannon Zhao <zhaoshenglong@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Hangaohuai <hangaohuai@huawei.com>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"Huangpeng (Peter)" <peter.huangpeng@huawei.com>
Subject: Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd
Date: Fri, 13 Mar 2015 13:17:40 +0800	[thread overview]
Message-ID: <550272F4.30309@huawei.com> (raw)
In-Reply-To: <1426172243-7830-1-git-send-email-pbonzini@redhat.com>

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

  parent reply	other threads:[~2015-03-13 13:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12 14:57 [Qemu-trivial] [PATCH] vl: fix resource leak with monitor_fdset_add_fd Paolo Bonzini
2015-03-12 14:57 ` [Qemu-devel] " Paolo Bonzini
2015-03-12 16:42 ` [Qemu-trivial] " Eric Blake
2015-03-12 16:42   ` Eric Blake
2015-03-12 23:37 ` [Qemu-trivial] " Fam Zheng
2015-03-12 23:37   ` Fam Zheng
2015-03-13  3:45 ` Patchew Tool
2015-03-13  5:17 ` Shannon Zhao [this message]
2015-03-13  5:17   ` Shannon Zhao
2015-03-13 12:53   ` [Qemu-trivial] " Paolo Bonzini
2015-03-13 12:53     ` Paolo Bonzini
2015-03-19  8:22 ` [Qemu-trivial] " Michael Tokarev
2015-03-19  8:22   ` [Qemu-devel] " Michael Tokarev
  -- strict thread matches above, loose matches on Subject: below --
2015-03-13 12:55 [Qemu-trivial] " Paolo Bonzini
2015-03-13 13:56 ` [Qemu-trivial] [Qemu-devel] " Eric Blake
2015-03-14  8:08   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=550272F4.30309@huawei.com \
    --to=zhaoshenglong@huawei.com \
    --cc=arei.gonglei@huawei.com \
    --cc=hangaohuai@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.