From patchwork Fri Mar 3 13:38:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 735080 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 3vZVg23GYgz9s1y for ; Sat, 4 Mar 2017 00:40:14 +1100 (AEDT) Received: from localhost ([::1]:58134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjnRL-0000dU-TH for incoming@patchwork.ozlabs.org; Fri, 03 Mar 2017 08:40:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjnPh-0008DZ-I8 for qemu-devel@nongnu.org; Fri, 03 Mar 2017 08:38:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjnPg-0001C0-LR for qemu-devel@nongnu.org; Fri, 03 Mar 2017 08:38:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cjnPc-0001AN-TT; Fri, 03 Mar 2017 08:38:25 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B87D4DD44; Fri, 3 Mar 2017 13:38:25 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v23DcImb021849; Fri, 3 Mar 2017 08:38:22 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 3 Mar 2017 21:38:15 +0800 Message-Id: <20170303133816.30303-2-famz@redhat.com> In-Reply-To: <20170303133816.30303-1-famz@redhat.com> References: <20170303133816.30303-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 03 Mar 2017 13:38: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] [PATCH 1/2] block: Don't use error_abort in blk_new_open 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: Kevin Wolf , Jeff Cody , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We have an errp and bdrv_root_attach_child can fail permission check, error_abort is not the best choice here. Signed-off-by: Fam Zheng --- block/block-backend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index daa7908..4eab68f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -213,7 +213,11 @@ BlockBackend *blk_new_open(const char *filename, const char *reference, } blk->root = bdrv_root_attach_child(bs, "root", &child_root, - perm, BLK_PERM_ALL, blk, &error_abort); + perm, BLK_PERM_ALL, blk, errp); + if (!blk->root) { + blk_unref(blk); + return NULL; + } return blk; }