From patchwork Wed Jul 23 21:22:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 373055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D9E7714019D for ; Thu, 24 Jul 2014 07:23:53 +1000 (EST) Received: from localhost ([::1]:46991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XA40t-0006I7-PJ for incoming@patchwork.ozlabs.org; Wed, 23 Jul 2014 17:23:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XA40H-0005NZ-7e for qemu-devel@nongnu.org; Wed, 23 Jul 2014 17:23:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XA40B-0006XW-3c for qemu-devel@nongnu.org; Wed, 23 Jul 2014 17:23:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XA40A-0006XL-Sl for qemu-devel@nongnu.org; Wed, 23 Jul 2014 17:23:07 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6NLN6eD019772 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Jul 2014 17:23:06 -0400 Received: from localhost (ovpn-112-30.phx2.redhat.com [10.3.112.30]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6NLN4on026303 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Wed, 23 Jul 2014 17:23:05 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Wed, 23 Jul 2014 17:22:57 -0400 Message-Id: <19050483a76326d639013bb572cea80888c9c86d.1406150099.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, sw@weilnetz.de, stefanha@redhat.com, mreitz@redhat.com Subject: [Qemu-devel] [PATCH v3 1/5] block: allow bdrv_unref() to be passed NULL pointers 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 If bdrv_unref() is passed a NULL BDS pointer, it is safe to exit with no operation. This will allow cleanup code to blindly call bdrv_unref() on a BDS that has been initialized to NULL. Reviewed-by: Max Reitz Signed-off-by: Jeff Cody --- block.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block.c b/block.c index 23f366d..f79efc8 100644 --- a/block.c +++ b/block.c @@ -5385,6 +5385,9 @@ void bdrv_ref(BlockDriverState *bs) * deleted. */ void bdrv_unref(BlockDriverState *bs) { + if (!bs) { + return; + } assert(bs->refcnt > 0); if (--bs->refcnt == 0) { bdrv_delete(bs);