public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Nolan <nolan@sigbus.net>
To: kvm <kvm@vger.kernel.org>
Subject: [PATCH] Fix minor memory leak
Date: Wed, 22 Apr 2009 15:15:14 -0700	[thread overview]
Message-ID: <1240438514.18771.36.camel@voxel> (raw)

Fix a memory leak.  No big deal, since it happens only a bounded # of
times at startup (as far as I can tell) but it makes valgrind complain.

I sent this here since qemu doesn't have the code in question (it
allocates buf on the stack, and thus guess_disk_lchs() usually won't
work with O_DIRECT).

Signed-off-by: Nolan Leake nolan <at> sigbus.net

diff --git a/qemu/block.c b/qemu/block.c
index 7a469ed..3cdebcd 100644
--- a/qemu/block.c
+++ b/qemu/block.c
@@ -771,8 +771,10 @@ static int guess_disk_lchs(BlockDriverState *bs,
     bdrv_get_geometry(bs, &nb_sectors);
 
     ret = bdrv_read(bs, 0, buf, 1);
-    if (ret < 0)
+    if (ret < 0) {
+        qemu_free(buf);
         return -1;
+    }
     /* test msdos magic */
     if (buf[510] != 0x55 || buf[511] != 0xaa) {
         qemu_free(buf);


             reply	other threads:[~2009-04-22 22:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22 22:15 Nolan [this message]
2009-04-24 20:42 ` [PATCH] Fix minor memory leak Marcelo Tosatti

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=1240438514.18771.36.camel@voxel \
    --to=nolan@sigbus.net \
    --cc=kvm@vger.kernel.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