Received: from eggs.gnu.org ([2001:4830:134:3::10]:46732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWh7k-0003U5-BC for qemu-devel@nongnu.org; Sat, 14 Mar 2015 04:08:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWh7h-0002B9-60 for qemu-devel@nongnu.org; Sat, 14 Mar 2015 04:08:44 -0400 From: Markus Armbruster References: <1426251334-29445-1-git-send-email-pbonzini@redhat.com> <5502EC71.9000009@redhat.com> Date: Sat, 14 Mar 2015 09:08:36 +0100 In-Reply-To: <5502EC71.9000009@redhat.com> (Eric Blake's message of "Fri, 13 Mar 2015 07:56:01 -0600") Message-ID: <87h9to6lx7.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] vl: fix resource leak with monitor_fdset_add_fd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-trivial@nongnu.org, Paolo Bonzini , famz@redhat.com, qemu-devel@nongnu.org, zhaoshenglong@huawei.com Eric Blake 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 >> --- >> v1->v2: line length [Fam], pass &error_abort [Shannon] >> --- >> vl.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> > > Reviewed-by: Eric Blake > >> 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.