From patchwork Wed Jun 7 17:50:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 772625 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 3wjbhW5TbQz9sDC for ; Thu, 8 Jun 2017 03:51:23 +1000 (AEST) Received: from localhost ([::1]:45505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIf73-00021D-EG for incoming@patchwork.ozlabs.org; Wed, 07 Jun 2017 13:51:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIf6D-0001qi-LO for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:50:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIf6C-0005tj-VK for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:50:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52488) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIf6A-0005sL-CK; Wed, 07 Jun 2017 13:50:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5645B80478; Wed, 7 Jun 2017 17:50:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5645B80478 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5645B80478 Received: from noname.redhat.com (ovpn-117-1.ams2.redhat.com [10.36.117.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D4CC189B1; Wed, 7 Jun 2017 17:50:24 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 7 Jun 2017 19:50:12 +0200 Message-Id: <1496857819-12466-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1496857819-12466-1-git-send-email-kwolf@redhat.com> References: <1496857819-12466-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 07 Jun 2017 17:50:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/8] block: Fix anonymous BBs in blk_root_inactivate() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Jeff Cody --- 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; }