Received: from eggs.gnu.org ([2001:4830:134:3::10]:54805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3f29-0005QE-7g for qemu-devel@nongnu.org; Mon, 29 Jul 2013 00:26:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3f20-0005xI-5x for qemu-devel@nongnu.org; Mon, 29 Jul 2013 00:26:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3f1z-0005xC-UE for qemu-devel@nongnu.org; Mon, 29 Jul 2013 00:26:00 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6T4Pxfk019071 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 29 Jul 2013 00:25:59 -0400 From: Fam Zheng Date: Mon, 29 Jul 2013 12:25:30 +0800 Message-Id: <1375071932-31627-3-git-send-email-famz@redhat.com> In-Reply-To: <1375071932-31627-1-git-send-email-famz@redhat.com> References: <1375071932-31627-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [RFC PATCH 2/4] nbd: call drive_put_ref() only if dinfo exists List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, imain@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Signed-off-by: Fam Zheng --- blockdev-nbd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 95f10c8..c75df19 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -72,7 +72,10 @@ static void nbd_close_notifier(Notifier *n, void *data) static void nbd_server_put_ref(NBDExport *exp) { BlockDriverState *bs = nbd_export_get_blockdev(exp); - drive_put_ref(drive_get_by_blockdev(bs)); + DriveInfo *dinfo = drive_get_by_blockdev(bs); + if (dinfo) { + drive_put_ref(dinfo); + } } void qmp_nbd_server_add(const char *device, bool has_writable, bool writable, -- 1.8.3.4