From patchwork Tue Aug 23 16:28:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sage Weil X-Patchwork-Id: 111146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 29425B70B7 for ; Wed, 24 Aug 2011 02:34:38 +1000 (EST) Received: from localhost ([::1]:35975 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qvtvv-0004M6-Kg for incoming@patchwork.ozlabs.org; Tue, 23 Aug 2011 12:34:35 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvtvV-000337-PG for qemu-devel@nongnu.org; Tue, 23 Aug 2011 12:34:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QvtvT-0000r6-D7 for qemu-devel@nongnu.org; Tue, 23 Aug 2011 12:34:09 -0400 Received: from cobra.newdream.net ([66.33.216.30]:55931) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvtvR-0000qn-68 for qemu-devel@nongnu.org; Tue, 23 Aug 2011 12:34:07 -0400 Received: from localhost.localdomain (aon.hq.newdream.net [64.111.111.107]) by cobra.newdream.net (Postfix) with ESMTPA id 7F30DBC764; Tue, 23 Aug 2011 09:39:03 -0700 (PDT) From: Sage Weil To: qemu-devel@nongnu.org Date: Tue, 23 Aug 2011 09:28:30 -0700 Message-Id: <1314116912-28685-1-git-send-email-sage@newdream.net> X-Mailer: git-send-email 1.7.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 66.33.216.30 Cc: Sage Weil Subject: [Qemu-devel] [PATCH 1/3] rbd: fix leak in failure path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Fix leak of s->snap when rados_create fails. Reported-by: Stefan Hajnoczi Signed-off-by: Sage Weil --- block/rbd.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index d5659cd..52b79fa 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -393,10 +393,6 @@ static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags) conf, sizeof(conf)) < 0) { return -EINVAL; } - s->snap = NULL; - if (snap_buf[0] != '\0') { - s->snap = qemu_strdup(snap_buf); - } r = rados_create(&s->cluster, NULL); if (r < 0) { @@ -404,6 +400,11 @@ static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags) return r; } + s->snap = NULL; + if (snap_buf[0] != '\0') { + s->snap = qemu_strdup(snap_buf); + } + if (strstr(conf, "conf=") == NULL) { r = rados_conf_read_file(s->cluster, NULL); if (r < 0) {