From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7fks-0005RW-55 for qemu-devel@nongnu.org; Tue, 31 May 2016 05:14:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7fkm-0005Dj-2g for qemu-devel@nongnu.org; Tue, 31 May 2016 05:14:29 -0400 Sender: Paolo Bonzini References: <20160531083455.31087-1-famz@redhat.com> From: Paolo Bonzini Message-ID: Date: Tue, 31 May 2016 11:14:05 +0200 MIME-Version: 1.0 In-Reply-To: <20160531083455.31087-1-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-stable@nongnu.org, Max Reitz , Stefan Hajnoczi 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. Thanks, Paolo