block: Fix leak of BdrvIoctlCompletionData when driver returns NULL
PATCH 1/1 block: Fix leak of BdrvIoctlCompletionData when driver returns NULL
"data" allocated in bdrv_co_do_ioctl is not freed. Free it before returning.
--- block/io.c | 1 + 1 file changed, 1 insertion(+)
block/io.c +1 -0
@@ -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)
Signature · 1 line
2.8.3
Quoted 16 lines · Fam Zheng
"data" allocated in
bdrv_co_do_ioctlis not freed. Free it before returning.Reported-by Kevin Wolf <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- block/io.c | 1 + 1 file changed, 1 insertion(+)block/io.c +0
-0
block/io.c static void bdrv_ioctl_bh_cb(void *opaque) · line 2326
Quoted 7 lines
block/io.c +1
-0@@ -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
Quoted 24 lines · Paolo Bonzini
Quoted 21 lines · Fam Zheng
"data" allocated in
bdrv_co_do_ioctlis not freed. Free it before returning.Reported-by Kevin Wolf <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- block/io.c | 1 + 1 file changed, 1 insertion(+)block/io.c +1
-0@@ -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); }
Quoted 8 lines
block/io.c static void bdrv_ioctl_bh_cb(void *opaque) · line 2326
Quoted 2 lines
block/io.c +0
-0static 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_*; andbdrv_co_maybe_schedule_bhalready provides it.
You are right, I missed that. Let's drop the BH.
Fam