From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNj63-0001uS-08 for qemu-devel@nongnu.org; Fri, 16 Nov 2018 13:44:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNj62-00038p-BD for qemu-devel@nongnu.org; Fri, 16 Nov 2018 13:44:02 -0500 From: John Snow Date: Fri, 16 Nov 2018 13:43:24 -0500 Message-Id: <20181116184324.8093-1-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH] migration/block-dirty-bitmap: Silence coverity CID 1390625 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: Fam Zheng , Stefan Hajnoczi , "Dr. David Alan Gilbert" , peter.maydell@linaro.org, Juan Quintela , John Snow Coverity warns that backing_bs() could give us a NULL pointer, which we then use without checking that it isn't. In our loop condition, we check bs && bs->drv as a point of habit, but by nature of the block graph, we cannot have null bs pointers here. This loop skips only implicit nodes, which always have children, so this loop should never encounter a null value. Tighten the loop condition to coax Coverity into dropping its false positive. Suggested-by: Stefan Hajnoczi Signed-off-by: John Snow --- migration/block-dirty-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 5e90f44c2f..00c068fda3 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -284,7 +284,7 @@ static int init_dirty_bitmap_migration(void) const char *drive_name = bdrv_get_device_or_node_name(bs); /* skip automatically inserted nodes */ - while (bs && bs->drv && bs->implicit) { + while (bs->drv && bs->implicit) { bs = backing_bs(bs); } -- 2.17.2