Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3936567pxb; Mon, 30 Aug 2021 14:29:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjvZ/eFdTmA3oiTJMTntG+d2LxmZZnBDykjCRYl3XskCTOIuBIZ/B1+aupaoXRDFQC0dpK X-Received: by 2002:a17:906:7ad7:: with SMTP id k23mr26368058ejo.405.1630358971026; Mon, 30 Aug 2021 14:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630358971; cv=none; d=google.com; s=arc-20160816; b=NyhtJ3288dkRD3ah0+9GDvVM1Yk/bhmObNoFtWSpnlHN4gtQmjmPrsO4XBAWbBnCl8 N4EbWSV2ciDHT//S0jpu92KMWqk6O7cJt1njADEC+8zJ3MCXxnokx808J98sIcCHRJLh 2JZGIrgu/jiVkZpLy17tcJgn+FyEiScwp/TzDUrkN/jsl4lIFgoWdaxnZjtWN9ZkL4Cw KgJh71MBU4T/1CPRLCeadkK6bd9t4SsKzHRW0bwWfVtSrkI6crjQdNUHgOXSGf8p7hOO qJBdqiOL0vkzDHabbI03UQNJTklQr8tw6G4+qNSjt8AVNG52PT+SCEAU5uwPx5pXIkm9 YLjQ== 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=rBPvEKTcZjAE3OuEvhz8lMdhHSp3hTsmUQtXV+X3g2E=; b=z9p7Mp2b4yyYfqoFqHwgt1UnXG/Cb1QoWyInUaZBD9DSnamJbCCDUZ8jxQmRMPsFWY JFm9/8iVnDIwaGEO9GVG31SxGwM7SHEnwEQxcf4YJsxbJgGyV4slnwxYYmpJ/YtvoWAN 20fADtVhAjjB0ZeiyKrFDu27LOIm33/BbaBNCS7Z1JqlGbE6pWmxnmwlUUJcm1Io4FEZ I0UKvXBUyt53xThj+41Pu8CTMGimM/Px8vAlMZ3p4MuxT5A+EYwZMSvKR69o5WZC6QFS X3DpIOpP4FrbAyP1ErCd4Zvd2IH8tt//ehror3Zhh2Cdui6dktGOrOf1qg7cNc+oCBLz tFSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=LqAGUGzQ; 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 i16si14258048ejw.721.2021.08.30.14.29.06; Mon, 30 Aug 2021 14:29:31 -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=LqAGUGzQ; 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 S238706AbhH3V1p (ORCPT + 99 others); Mon, 30 Aug 2021 17:27:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237630AbhH3V1F (ORCPT ); Mon, 30 Aug 2021 17:27:05 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E350C0613D9; Mon, 30 Aug 2021 14:26:11 -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=rBPvEKTcZjAE3OuEvhz8lMdhHSp3hTsmUQtXV+X3g2E=; b=LqAGUGzQh3aRuomO3GLoPt67ss jVAXwMHOotPEFCmxqAKMjxTbW+MYa0NvwOz+9m9HVRiN+EwpTFtjf3WWjprV0f1d6VieaR/ETCXlP 5f0SRpkvbgHDeSaW9WeTCzDiC0cNdXS5egKoJ4lrFuqWbbKxtkq+2gMC3WGSyPjny9jJOisdFgIOq jr5qrfi7dzWpr1iNIAY7Jiu6rn1uSIxtXUm8Q6mH5n3mwEAxFPlZlXPv2h4gMiHHOSqoftuuvpEEE ZAfMiRpHJdKSsb5VU+bdCbZmU3a+b1eh8lik03BH7fQPLAE2ymcem0hCxLdls4byMuetMxyBVW/U9 APVAiEdQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mKomk-000ciL-Uw; Mon, 30 Aug 2021 21:25:42 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain , Christoph Hellwig Subject: [PATCH v3 8/8] nbd: add error handling support for add_disk() Date: Mon, 30 Aug 2021 14:25:38 -0700 Message-Id: <20210830212538.148729-9-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210830212538.148729-1-mcgrof@kernel.org> References: <20210830212538.148729-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 add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Reviewed-by: Christoph Hellwig Signed-off-by: Luis Chamberlain --- drivers/block/nbd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 5170a630778d..741365295157 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1757,7 +1757,9 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) disk->fops = &nbd_fops; disk->private_data = nbd; sprintf(disk->disk_name, "nbd%d", index); - add_disk(disk); + err = add_disk(disk); + if (err) + goto out_err_disk; /* * Now publish the device. @@ -1766,6 +1768,8 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) nbd_total_devices++; return nbd; +out_err_disk: + blk_cleanup_disk(disk); out_free_idr: mutex_lock(&nbd_index_mutex); idr_remove(&nbd_index_idr, index); -- 2.30.2