From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9JdK-0001IZ-Pe for qemu-devel@nongnu.org; Mon, 21 Jul 2014 15:52:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X9JdE-0004jw-LS for qemu-devel@nongnu.org; Mon, 21 Jul 2014 15:52:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9JdE-0004ja-D7 for qemu-devel@nongnu.org; Mon, 21 Jul 2014 15:52:20 -0400 From: Jeff Cody Date: Mon, 21 Jul 2014 15:52:10 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH v2 1/5] block: allow bdrv_unref() to be passed NULL pointers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, sw@weilnetz.de, stefanha@redhat.com, mreitz@redhat.com 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); -- 1.9.3