All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Shannon Zhao <zhaoshenglong@huawei.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:53:15 +0100	[thread overview]
Message-ID: <5502DDBB.8070002@redhat.com> (raw)
In-Reply-To: <550272F4.30309@huawei.com>



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


WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: Shannon Zhao <zhaoshenglong@huawei.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:53:15 +0100	[thread overview]
Message-ID: <5502DDBB.8070002@redhat.com> (raw)
In-Reply-To: <550272F4.30309@huawei.com>



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

  reply	other threads:[~2015-03-13 12:53 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 ` [Qemu-trivial] " Shannon Zhao
2015-03-13  5:17   ` Shannon Zhao
2015-03-13 12:53   ` Paolo Bonzini [this message]
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=5502DDBB.8070002@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=hangaohuai@huawei.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=zhaoshenglong@huawei.com \
    /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.