[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH] block: Fix leak of BdrvIoctlCompletionData when
From: |
Fam Zheng |
Subject: |
Re: [Qemu-block] [PATCH] block: Fix leak of BdrvIoctlCompletionData when driver returns NULL |
Date: |
Tue, 31 May 2016 18:49:40 +0800 |
User-agent: |
Mutt/1.6.1 (2016-04-27) |
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: address@hidden
> > Reported-by: Kevin Wolf <address@hidden>
> > Signed-off-by: Fam Zheng <address@hidden>
> > ---
> > 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