From patchwork Wed Apr 22 22:15:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nolan X-Patchwork-Id: 19434 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3MMOEou028094 for ; Wed, 22 Apr 2009 22:24:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752596AbZDVWYL (ORCPT ); Wed, 22 Apr 2009 18:24:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753252AbZDVWYL (ORCPT ); Wed, 22 Apr 2009 18:24:11 -0400 Received: from phong.sigbus.net ([65.49.35.42]:48046 "EHLO phong.sigbus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752306AbZDVWYK (ORCPT ); Wed, 22 Apr 2009 18:24:10 -0400 X-Greylist: delayed 532 seconds by postgrey-1.27 at vger.kernel.org; Wed, 22 Apr 2009 18:24:10 EDT Received: from localhost (c-71-202-202-194.hsd1.ca.comcast.net [71.202.202.194]) by phong.sigbus.net (Postfix) with ESMTPSA id C334A95C0D9 for ; Wed, 22 Apr 2009 15:15:15 -0700 (PDT) Subject: [PATCH] Fix minor memory leak From: Nolan To: kvm Date: Wed, 22 Apr 2009 15:15:14 -0700 Message-Id: <1240438514.18771.36.camel@voxel> Mime-Version: 1.0 X-Mailer: Evolution 2.24.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 sigbus.net --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);