Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3933554pxb; Mon, 30 Aug 2021 14:28:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXz4fhcuPTz1oZlwEvJARDNA1sEbVRDGI1Pk/AoqV+Qw2cT7iu7qx2dQWIAXfHF7/U2KVy X-Received: by 2002:a17:906:a98e:: with SMTP id jr14mr27236395ejb.450.1630358881790; Mon, 30 Aug 2021 14:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630358881; cv=none; d=google.com; s=arc-20160816; b=MSax4JUR0CkGTH61zSfTMntR3idVOZyjtvKqJ4pvhKb51D8XJr3mqf2oC6wbae28nf PBZHMJnCu9ZaWYGaCsQtpV3M+AxzUZlb3LsQkVUYNIhn3FPuxkAlLB6p8q11YNlSviTV TNiWfCoxyBIVD3nTYUhkJaG7UU4b2Q6hnOBgsLz/PaANHiclDEDrhkKq8sA5xCUxFttA mGSrcqxkfzBflkkbTJhyPRGsipvWchSNAYVEXtvq8OIZKRYTsHWqxWBXVcmVeVk3WjPX j/DUvTpv8eCYp0Z0/0uiK9U3B2gbHHA79qEpLsqzCHQ4v0xJodp6FRtC44ds0dIyNFvY iBWQ== 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=hc6+PdzrnVmkCNkRHjEi79cwLRliAERVgct1KBgFYaI=; b=fhtIEJKeCoUCp61PM+p5UarjF/f3PyKym+XI0YAI3RMd9jqfU/YVXM+zrT+stEFm// 6dVR5hcHBDXUzPnUHBY/zljTNpEsCG+pxrBua9Wubk+YYL9mOuiWEMQI6/udDe+vrgWr AOYexrRViCQ6nJMXOLchTtyTmS8Z494Bi8646NcdQ3ajsB2yc5NMKgIP7aWzDPtc4GnA MIpMLfg72WrbjrxPDMPRL8bRWG/a3alYaxSvxF9edtXI39BkjEP1soFVSv+6O/1JaSxH sJaBmtGV9QQYv2EUhmatCcSjj8eFx16TJluOBGbLVxpBtXjnQMMyyg29pTaEyoctAzft /23Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="pA/GR6Bz"; 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 aq7si5485086ejc.75.2021.08.30.14.27.38; Mon, 30 Aug 2021 14:28:01 -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="pA/GR6Bz"; 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 S233583AbhH3V1G (ORCPT + 99 others); Mon, 30 Aug 2021 17:27:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbhH3V1C (ORCPT ); Mon, 30 Aug 2021 17:27:02 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BA0EC06175F; Mon, 30 Aug 2021 14:26:08 -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=hc6+PdzrnVmkCNkRHjEi79cwLRliAERVgct1KBgFYaI=; b=pA/GR6Bz19QHdhFRRSA2ON0Tgx +eRSmEnPNrh32hkf3MZlIDGxo3EtZWmJ/GB6tK0cGC5uZNwwgkk7imPqSkxXOQ33HVPuMHq907z+m u+AZjjVW4ShjB+GQq3rjLyhzNZmnjQe6GINo+WzdyvmVEnMJ3CmlWZStlGpna7Ds4l4DC6Sf4vktV QJSPg+gSjj+9KgA+vmOIC8GeVsKsW9lTzyy8tzKfvyCVoFhDwzByxJlA8N6htHVAFTZAU73HNG18j yWOXgy8/CWk3+kNIdImLk+pyi1JIWItQxykB+kpBJFOzXKX+coN8bFhLz3cGLILv/24mHpqzKU6pW 0LG628pg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mKomk-000ciJ-Tc; 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 7/8] loop: add error handling support for add_disk() Date: Mon, 30 Aug 2021 14:25:37 -0700 Message-Id: <20210830212538.148729-8-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/loop.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index fa1c298a8cfb..b8b9e2349e77 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2393,10 +2393,17 @@ static int loop_add(int i) disk->events = DISK_EVENT_MEDIA_CHANGE; disk->event_flags = DISK_EVENT_FLAG_UEVENT; sprintf(disk->disk_name, "loop%d", i); - add_disk(disk); + + err = add_disk(disk); + if (err) + goto out_cleanup_disk; + mutex_unlock(&loop_ctl_mutex); + return i; +out_cleanup_disk: + blk_cleanup_disk(disk); out_cleanup_tags: blk_mq_free_tag_set(&lo->tag_set); out_free_idr: -- 2.30.2