From: Zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: RE: Memory leak in transfer_memory_block()?
Date: Thu, 18 Jun 2020 06:49:51 +0000 [thread overview]
Message-ID: <8562bcb768514568b14788e801aee681@huawei.com> (raw)
In-Reply-To: <87h7v9szpe.fsf@dusky.pond.sub.org>
> -----Original Message-----
> From: Markus Armbruster [mailto:armbru@redhat.com]
> Sent: Thursday, June 18, 2020 1:36 PM
> To: Zhanghailiang <zhang.zhanghailiang@huawei.com>
> Cc: qemu-devel@nongnu.org; Michael Roth <mdroth@linux.vnet.ibm.com>
> Subject: Memory leak in transfer_memory_block()?
>
> We appear to leak an Error object when ga_read_sysfs_file() fails with
> errno != ENOENT unless caller passes true @sys2memblk:
>
> static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool
> sys2memblk,
> GuestMemoryBlockResponse
> *result,
> Error **errp)
> {
> [...]
> if (local_err) {
>
> We have an Error object.
>
> /* treat with sysfs file that not exist in old kernel */
> if (errno == ENOENT) {
>
> Case 1: ENOENT; we free it. Good.
>
> error_free(local_err);
> if (sys2memblk) {
> mem_blk->online = true;
> mem_blk->can_offline = false;
> } else if (!mem_blk->online) {
> result->response =
>
> GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_NOT_SUPPORTED;
> }
> } else {
>
> Case 2: other than ENOENT
>
> if (sys2memblk) {
>
> Case 2a: sys2memblk; we pass it to the caller. Good.
>
> error_propagate(errp, local_err);
> } else {
>
> Case 2b: !sys2memblk; ???
>
Good catch! I think we should pass the error info back to the caller,
Let's record this error for debug when it happens.
> result->response =
>
> GUEST_MEMORY_BLOCK_RESPONSE_TYPE_OPERATION_FAILED;
> }
> }
> goto out2;
> }
> [...]
> out2:
> g_free(status);
> close(dirfd);
> out1:
> if (!sys2memblk) {
> result->has_error_code = true;
> result->error_code = errno;
> }
> }
>
> What is supposed to be done with @local_err in case 2b?
next prev parent reply other threads:[~2020-06-18 6:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 5:35 Memory leak in transfer_memory_block()? Markus Armbruster
2020-06-18 6:49 ` Zhanghailiang [this message]
2020-06-22 8:23 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8562bcb768514568b14788e801aee681@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).