From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7hF7-0002Pr-Vr for qemu-devel@nongnu.org; Tue, 31 May 2016 06:49:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7hF7-0007UT-01 for qemu-devel@nongnu.org; Tue, 31 May 2016 06:49:49 -0400 Date: Tue, 31 May 2016 18:49:40 +0800 From: Fam Zheng Message-ID: <20160531104940.GA25364@ad.usersys.redhat.com> References: <20160531083455.31087-1-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] block: Fix leak of BdrvIoctlCompletionData when driver returns NULL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Kevin Wolf , qemu-block@nongnu.org, qemu-stable@nongnu.org, Max Reitz , Stefan Hajnoczi On Tue, 05/31 11:14, Paolo Bonzini wrote: > > > On 31/05/2016 10:34, Fam Zheng wrote: > > "data" allocated in bdrv_co_do_ioctl is not freed. Free it before > > returning. > > > > Cc: qemu-stable@nongnu.org > > Reported-by: Kevin Wolf > > Signed-off-by: Fam Zheng > > --- > > block/io.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/block/io.c b/block/io.c > > index 2d832aa..aa5a5d7 100644 > > --- a/block/io.c > > +++ b/block/io.c > > @@ -2320,6 +2320,7 @@ static void bdrv_ioctl_bh_cb(void *opaque) > > > > bdrv_co_io_em_complete(data->co, -ENOTSUP); > > qemu_bh_delete(data->bh); > > + g_free(data); > > } > > > > static int bdrv_co_do_ioctl(BlockDriverState *bs, int req, void *buf) > > > > Is the bottom half needed at all? Why can't you just do "co.ret = > -ENOTSUP;"? The bottom half indirection is not needed for coroutine > functions, only for bdrv_aio_*; and bdrv_co_maybe_schedule_bh already > provides it. > You are right, I missed that. Let's drop the BH. Fam