From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG0JF-0001j7-NS for qemu-devel@nongnu.org; Wed, 31 May 2017 05:52:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG0JF-0004pv-10 for qemu-devel@nongnu.org; Wed, 31 May 2017 05:52:57 -0400 From: Kevin Wolf Date: Wed, 31 May 2017 11:52:44 +0200 Message-Id: <1496224367-24935-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1496224367-24935-1-git-send-email-kwolf@redhat.com> References: <1496224367-24935-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v3 1/4] block: Fix anonymous BBs in blk_root_inactivate() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, eblake@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org blk->name isn't an array, but a pointer that can be NULL. Checking for an anonymous BB must involve a NULL check first, otherwise we get crashes. Signed-off-by: Kevin Wolf Reviewed-by: Fam Zheng Reviewed-by: Juan Quintela Reviewed-by: Eric Blake --- block/block-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index f3a6008..7d7f369 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -168,7 +168,7 @@ static int blk_root_inactivate(BdrvChild *child) * this point because the VM is stopped) and unattached monitor-owned * BlockBackends. If there is still any other user like a block job, then * we simply can't inactivate the image. */ - if (!blk->dev && !blk->name[0]) { + if (!blk->dev && !blk_name(blk)[0]) { return -EPERM; } -- 1.8.3.1