block: Fix leaks of opts in block drivers
v3 cover block: Fix leaks of opts in block drivers
Remember to call qemu_opts_del before function returning.
v3: Fix nfs return code again! (Benoit)
v2: Drop qcow2 fix since it's duplicated with Max's "[PATCH 0/4]
qapi/block-core: Add "new" qcow2 options" series. (Max) Fix nfs return code. (Benoit)
Add Beniot's rev-by lines in other patches. (Thanks for reviewing)
Fam Zheng (3):
nfs: Fix leak of opts in nfs_file_open
blkverify: Fix leak of opts in blkverify_open
quorum: Fix leak of opts in quorum_open
block/blkverify.c | 1 + block/nfs.c | 10 +++++++--- block/quorum.c | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.0
PATCH v3 1/3 nfs: Fix leak of opts in nfs_file_open
--- block/nfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
block/nfs.c +7 -3
@@ -393,16 +393,20 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,qemu_opts_absorb_qdict (opts, options, &local_err);if (local_err) {error_propagate (errp, local_err); -return -EINVAL ; + ret = -EINVAL ; + goto out; } ret =nfs_client_open (client,qemu_opt_get (opts,"filename" ), (flags &BDRV_O_RDWR ) ?O_RDWR :O_RDONLY , errp);if (ret <0 ) { -return ret; + goto out; } bs->total_sectors = ret; -return 0 ; + ret =0 ; +out: +qemu_opts_del (opts); +return ret; }static int nfs_file_create (const char *url,QemuOpts *opts,Error **errp)
Signature · 1 line
2.1.0
Re: [Qemu-devel] [PATCH v3 1/3] nfs: Fix leak of opts in nfs_file_open
Quoted 37 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- block/nfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)block/nfs.c +7
-3@@ -393,16 +393,20 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,qemu_opts_absorb_qdict (opts, options, &local_err);if (local_err) {error_propagate (errp, local_err); -return -EINVAL ; + ret = -EINVAL ; + goto out; } ret =nfs_client_open (client,qemu_opt_get (opts,"filename" ), (flags &BDRV_O_RDWR ) ?O_RDWR :O_RDONLY , errp);if (ret <0 ) { -return ret; + goto out; } bs->total_sectors = ret; -return 0 ; + ret =0 ; +out: +qemu_opts_del (opts); +return ret; }static int nfs_file_create (const char *url,QemuOpts *opts,Error **errp)Signature · 1 line
2.1.0
PATCH v3 2/3 blkverify: Fix leak of opts in blkverify_open
In reply to Fam Zheng--- block/blkverify.c | 1 + 1 file changed, 1 insertion(+)
block/blkverify.c +1 -0
@@ -158,6 +158,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, ret =0 ; fail: +qemu_opts_del (opts);return ret; }
Signature · 1 line
2.1.0
PATCH v3 3/3 quorum: Fix leak of opts in quorum_open
In reply to Fam Zheng--- block/quorum.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/quorum.c +2 -1
@@ -796,7 +796,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, {BDRVQuorumState *s = bs->opaque;Error *local_err =NULL ; -QemuOpts *opts; +QemuOpts *opts =NULL ;bool *opened;QDict *sub =NULL ;QList *list =NULL ;
@@ -908,6 +908,7 @@ close_exit:g_free (s->bs);g_free (opened); exit: +qemu_opts_del (opts);/* propagate error */ if (local_err) {error_propagate (errp, local_err);
Signature · 1 line
2.1.0
Stefan Hajnoczi
AppliedQuoted 15 lines · Fam Zheng
Remember to call
qemu_opts_delbefore function returning.v3: Fix nfs return code again! (Benoit)
v2: Drop qcow2 fix since it's duplicated with Max's "[PATCH 0/4]
qapi/block-core: Add "new" qcow2 options" series. (Max) Fix nfs return code. (Benoit)
Add Beniot's rev-by lines in other patches. (Thanks for reviewing)Fam Zheng (3):
nfs: Fix leak of opts innfs_file_open
blkverify: Fix leak of opts inblkverify_open
quorum: Fix leak of opts inquorum_open
Quoted 9 lines
block/blkverify.c | 1 + block/nfs.c | 10 +++++++--- block/quorum.c | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-)Signature · 1 line
2.1.0
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan