From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFoA0-0004Zt-6Q for qemu-devel@nongnu.org; Fri, 08 Aug 2014 13:41:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFo9t-0006lA-RC for qemu-devel@nongnu.org; Fri, 08 Aug 2014 13:41:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFo9t-0006ky-Iq for qemu-devel@nongnu.org; Fri, 08 Aug 2014 13:40:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s78HeqnN016971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 8 Aug 2014 13:40:53 -0400 From: Kevin Wolf Date: Fri, 8 Aug 2014 19:39:35 +0200 Message-Id: <1407519603-6635-35-git-send-email-kwolf@redhat.com> In-Reply-To: <1407519603-6635-1-git-send-email-kwolf@redhat.com> References: <1407519603-6635-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 34/62] 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 From: Jeff Cody 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 Signed-off-by: Kevin Wolf --- block.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block.c b/block.c index 13a1059..a8962ab 100644 --- a/block.c +++ b/block.c @@ -5388,6 +5388,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.8.3.1