* [Qemu-devel] [PATCH] block/rbd: fix memory leak
@ 2014-12-04 6:34 arei.gonglei
2014-12-04 6:51 ` Amos Kong
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: arei.gonglei @ 2014-12-04 6:34 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, josh.durgin, Gonglei, Markus Armbruster, stefanha
From: Gonglei <arei.gonglei@huawei.com>
Variable local_err going out of scope
leaks the storage it points to.
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
block/rbd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
index 5b5a64a..f3ab2dd 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -459,7 +459,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
r = rados_create(&s->cluster, clientname);
if (r < 0) {
- error_setg(&local_err, "error initializing");
+ error_setg(errp, "error initializing");
goto failed_opts;
}
@@ -495,19 +495,19 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
r = rados_connect(s->cluster);
if (r < 0) {
- error_setg(&local_err, "error connecting");
+ error_setg(errp, "error connecting");
goto failed_shutdown;
}
r = rados_ioctx_create(s->cluster, pool, &s->io_ctx);
if (r < 0) {
- error_setg(&local_err, "error opening pool %s", pool);
+ error_setg(errp, "error opening pool %s", pool);
goto failed_shutdown;
}
r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
if (r < 0) {
- error_setg(&local_err, "error reading header from %s", s->name);
+ error_setg(errp, "error reading header from %s", s->name);
goto failed_open;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block/rbd: fix memory leak
2014-12-04 6:34 [Qemu-devel] [PATCH] block/rbd: fix memory leak arei.gonglei
@ 2014-12-04 6:51 ` Amos Kong
2014-12-04 7:03 ` Gonglei
2014-12-11 6:53 ` Gonglei
2014-12-12 13:18 ` Stefan Hajnoczi
2 siblings, 1 reply; 5+ messages in thread
From: Amos Kong @ 2014-12-04 6:51 UTC (permalink / raw)
To: arei.gonglei; +Cc: kwolf, josh.durgin, qemu-devel, stefanha, Markus Armbruster
[-- Attachment #1: Type: text/plain, Size: 1999 bytes --]
On Thu, Dec 04, 2014 at 02:34:11PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> Variable local_err going out of scope
> leaks the storage it points to.
>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> block/rbd.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/block/rbd.c b/block/rbd.c
> index 5b5a64a..f3ab2dd 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -459,7 +459,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
> clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
> r = rados_create(&s->cluster, clientname);
> if (r < 0) {
> - error_setg(&local_err, "error initializing");
> + error_setg(errp, "error initializing");
> goto failed_opts;
> }
>
> @@ -495,19 +495,19 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
>
> r = rados_connect(s->cluster);
> if (r < 0) {
> - error_setg(&local_err, "error connecting");
> + error_setg(errp, "error connecting");
> goto failed_shutdown;
> }
>
> r = rados_ioctx_create(s->cluster, pool, &s->io_ctx);
> if (r < 0) {
> - error_setg(&local_err, "error opening pool %s", pool);
> + error_setg(errp, "error opening pool %s", pool);
> goto failed_shutdown;
> }
>
> r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
> if (r < 0) {
> - error_setg(&local_err, "error reading header from %s", s->name);
> + error_setg(errp, "error reading header from %s", s->name);
> goto failed_open;
> }
'local_err' was defined for collecting error insider qemu_opts_absorb_qdict().
We should set error to 'errp', then the error can be passed to caller,
and free the memory in future.
Reviewed-by: Amos Kong <akong@redhat.com>
--
Amos.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block/rbd: fix memory leak
2014-12-04 6:51 ` Amos Kong
@ 2014-12-04 7:03 ` Gonglei
0 siblings, 0 replies; 5+ messages in thread
From: Gonglei @ 2014-12-04 7:03 UTC (permalink / raw)
To: Amos Kong
Cc: kwolf@redhat.com, josh.durgin@inktank.com, qemu-devel@nongnu.org,
stefanha@redhat.com, Markus Armbruster
On 2014/12/4 14:51, Amos Kong wrote:
> 'local_err' was defined for collecting error insider qemu_opts_absorb_qdict().
> We should set error to 'errp', then the error can be passed to caller,
> and free the memory in future.
>
> Reviewed-by: Amos Kong <akong@redhat.com>
Thanks :)
Regards,
-Gonglei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block/rbd: fix memory leak
2014-12-04 6:34 [Qemu-devel] [PATCH] block/rbd: fix memory leak arei.gonglei
2014-12-04 6:51 ` Amos Kong
@ 2014-12-11 6:53 ` Gonglei
2014-12-12 13:18 ` Stefan Hajnoczi
2 siblings, 0 replies; 5+ messages in thread
From: Gonglei @ 2014-12-11 6:53 UTC (permalink / raw)
To: Gonglei (Arei)
Cc: kwolf@redhat.com, josh.durgin@inktank.com, qemu-devel@nongnu.org,
stefanha@redhat.com, Markus Armbruster
On 2014/12/4 14:34, Gonglei (Arei) wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> Variable local_err going out of scope
> leaks the storage it points to.
>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> block/rbd.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
Ping...
> diff --git a/block/rbd.c b/block/rbd.c
> index 5b5a64a..f3ab2dd 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -459,7 +459,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
> clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
> r = rados_create(&s->cluster, clientname);
> if (r < 0) {
> - error_setg(&local_err, "error initializing");
> + error_setg(errp, "error initializing");
> goto failed_opts;
> }
>
> @@ -495,19 +495,19 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
>
> r = rados_connect(s->cluster);
> if (r < 0) {
> - error_setg(&local_err, "error connecting");
> + error_setg(errp, "error connecting");
> goto failed_shutdown;
> }
>
> r = rados_ioctx_create(s->cluster, pool, &s->io_ctx);
> if (r < 0) {
> - error_setg(&local_err, "error opening pool %s", pool);
> + error_setg(errp, "error opening pool %s", pool);
> goto failed_shutdown;
> }
>
> r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
> if (r < 0) {
> - error_setg(&local_err, "error reading header from %s", s->name);
> + error_setg(errp, "error reading header from %s", s->name);
> goto failed_open;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block/rbd: fix memory leak
2014-12-04 6:34 [Qemu-devel] [PATCH] block/rbd: fix memory leak arei.gonglei
2014-12-04 6:51 ` Amos Kong
2014-12-11 6:53 ` Gonglei
@ 2014-12-12 13:18 ` Stefan Hajnoczi
2 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2014-12-12 13:18 UTC (permalink / raw)
To: arei.gonglei; +Cc: kwolf, josh.durgin, qemu-devel, stefanha, Markus Armbruster
[-- Attachment #1: Type: text/plain, Size: 491 bytes --]
On Thu, Dec 04, 2014 at 02:34:11PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> Variable local_err going out of scope
> leaks the storage it points to.
>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> block/rbd.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-12-12 13:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-04 6:34 [Qemu-devel] [PATCH] block/rbd: fix memory leak arei.gonglei
2014-12-04 6:51 ` Amos Kong
2014-12-04 7:03 ` Gonglei
2014-12-11 6:53 ` Gonglei
2014-12-12 13:18 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).