Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1590158pxb; Fri, 27 Aug 2021 12:20:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkkj+fMASr7IKpZIkWmA+pLWq9gOwNKh0ZJ2jxlEkEYiHiuskFAFV3EBivGdBwIvWlf2HJ X-Received: by 2002:a05:6e02:b28:: with SMTP id e8mr7500541ilu.7.1630092035413; Fri, 27 Aug 2021 12:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630092035; cv=none; d=google.com; s=arc-20160816; b=IqNfAoLAar+7cVFCTerRx21OfbwRBAA8Fw0O//Da50h3TXXrTViLtAH1z/7XcQ/gEx 4HLn2C5lOLIi71JWeEBHtbLQsGtjx+FT4SBQmPIrZE86Ka9Pb63gqSDk1LjzClsBTKjo eVupVnxrA183vQTtRW0s3rp42whKd7kqhtyYFLvkUWtZ8XfWGAHIgVUv02K+thLKKOjb ybqJdIfKrkYcuXvdcghrWkp2q1rS8ky2IS7yO1vUMYz2C5ix/skIbPWMr6uDL9eOjscI qWgNIaPOAKEPYnhHFCXllEO91z53mrTGJNuFRw8r1ZplnkhNHl4iy0U7lmNdRUX8y/1/ LYow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KzwjtOOfTw3O+GVEV4PWsbl44+6kR5dP++6Kf9jn+mM=; b=JGhXl5g4tNGKfyWcAwzNeBMEGd34W4iZtL/pBAlqE0Zf9ZukaH5rLpplRyaU8V1dy5 0QdZtAFdYP5Joq0B3vaBfhUPhMqHBD3I0fdlqSTu80NYIB5R202f9plhQ4GbxFPR80JN ye+1Sf8/lejQgj10sbuC5oaFz6yuo7FxUAddxXMeseF0DPxGwlbhJotZa27/uEvmEdRB qHgkto4YOTdRipzr/YQBnZqHh51Qb0gZOjjvc5bqVzQoIPb28dkUkMKQW/9zudkl4gpD rLtDLaEH7ePff0jr0pjdmT/20YliwZWVt2MgecHy5jvxmL/Xq9OmTGZCzJ74qp+qc5U4 OYiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=22AEbFZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si7120440ilf.100.2021.08.27.12.20.24; Fri, 27 Aug 2021 12:20:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=22AEbFZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231543AbhH0TUX (ORCPT + 99 others); Fri, 27 Aug 2021 15:20:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbhH0TTP (ORCPT ); Fri, 27 Aug 2021 15:19:15 -0400 Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D9FC0613CF; Fri, 27 Aug 2021 12:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=KzwjtOOfTw3O+GVEV4PWsbl44+6kR5dP++6Kf9jn+mM=; b=22AEbFZXnUBijnmWHGiRM2ca1G I7DdRw6q+h1AAkzSSsriWrRm6rwQttirydRWTxP+Dc9ypWHGLmyBkFTpVBbwVVN07dFqnD9aBeiW1 oTj47B/RZJlwgZTa3Mvy0Z2HINQE1ANIR5vX3wgFRLERYG89rawNAiCgeBr3FqDrB/czdQF1B6XIp Y+XgiGc3NadMhe8cZIBRxzuCtj3wgELhBZsQklN3du2PKCibgxt1CkHiHjYKl0SXXjZCp3PdmSI0U D1Oum0CpCf1bGZ/OZm1TiyGZOKJOMo0Bl8dluQpmwqyy42PlPzUePzImhvPpzLv9ZMVomsm/80u0z pidRqVQg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJhMh-00D5BC-FT; Fri, 27 Aug 2021 19:18:11 +0000 From: Luis Chamberlain To: axboe@kernel.dk, colyli@suse.de, kent.overstreet@gmail.com, kbusch@kernel.org, sagi@grimberg.me, vishal.l.verma@intel.com, dan.j.williams@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, konrad.wilk@oracle.com, roger.pau@citrix.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org Cc: xen-devel@lists.xenproject.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 09/10] xen-blkfront: add error handling support for add_disk() Date: Fri, 27 Aug 2021 12:18:08 -0700 Message-Id: <20210827191809.3118103-10-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210827191809.3118103-1-mcgrof@kernel.org> References: <20210827191809.3118103-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We never checked for errors on device_add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. The function xlvbd_alloc_gendisk() typically does the unwinding on error on allocating the disk and creating the tag, but since all that error handling was stuffed inside xlvbd_alloc_gendisk() we must repeat the tag free'ing as well. We set the info->rq to NULL to ensure blkif_free() doesn't crash on blk_mq_stop_hw_queues() on device_add_disk() error as the queue will be long gone by then. Signed-off-by: Luis Chamberlain --- drivers/block/xen-blkfront.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 715bfa8aca7f..9fe28af5f6d9 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2343,7 +2343,13 @@ static void blkfront_connect(struct blkfront_info *info) for_each_rinfo(info, rinfo, i) kick_pending_request_queues(rinfo); - device_add_disk(&info->xbdev->dev, info->gd, NULL); + err = device_add_disk(&info->xbdev->dev, info->gd, NULL); + if (err) { + blk_cleanup_disk(info->gd); + blk_mq_free_tag_set(&info->tag_set); + info->rq = NULL; + goto fail; + } info->is_ready = 1; return; -- 2.30.2