Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp712241pxb; Thu, 2 Sep 2021 13:16:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx+2+WAaHu13ZWQZWGkYweOBRFGUYAIwo1ylDNthIzhmhvghqO7Pwl23v5ql5jGDSiF0jB X-Received: by 2002:a17:906:4c42:: with SMTP id d2mr5686453ejw.301.1630613793392; Thu, 02 Sep 2021 13:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630613793; cv=none; d=google.com; s=arc-20160816; b=H3xspP4FzHzEV20HI2UnjxIYnPBf7C9wI7l2+tldxGeGd5dusrmEWJvDHoBSaWw0mX jYn+qTUxvodnncckbmDnJevqXWDmTE7F37sh8mLYE5xi08GFrWINHDMcNSezGBOn4paZ f/773YPAX8xe+R/gdw0UQ30kbjuALQ7ePW+Rh19wdcVyv08rp+PGm7BB8OKPp3I4iSRO OL7AL7qCExf/+LttbdI3W6SYKcKApF1vN8q2Ws3H8xUAfj+/it0m5rBOFfk+Hajj/7kx 0PBNZEXgT24aSkZxPVRAmDZg7qH88BUF1z02NlVHFNkJwcUtD6QZqNM0pGi3op05KTEN DdTg== 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=Vee+7CSHZ5OpNHjor5aboTDtNXHhzGkI8kD6MNYblNI=; b=A6X9DV3DuihmonEweICnKI4zMcQzeBBkGLCwr5SJ80KnbL5NLuL/I2XS0+6flVJj1v nSwkjbQW8DOuAlxJvrt3Xbt6N2aDR6OxiSre7QpVAi0WoS9oZJy/VEhsl18BhA9mHFvA a3cfuDxDkLAFz2lUynnaRq+lmaOCF3EQiE6SgQyfbFSDYCSIEKp7lhuTLLt6Li3dMEZh WMPxYvenj44RaCHq0hCoPGyqPH/pT4SnBKSMG8iYgqZ+5MzEKn4gsUlrJ2EYo9TOcjYC JOqVB2/MM5JgvGnbY1G02ubooHVLTzWz89SuGaEBc1Ggze+7gpzmBExS7t1NFXDstlcn zS3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="a2/GQq9O"; 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 o1si3746215ejy.319.2021.09.02.13.16.10; Thu, 02 Sep 2021 13:16:33 -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="a2/GQq9O"; 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 S1347171AbhIBRmr (ORCPT + 99 others); Thu, 2 Sep 2021 13:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347025AbhIBRmU (ORCPT ); Thu, 2 Sep 2021 13:42:20 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFC1DC061757; Thu, 2 Sep 2021 10:41:21 -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=Vee+7CSHZ5OpNHjor5aboTDtNXHhzGkI8kD6MNYblNI=; b=a2/GQq9OVg6RViwxWUcGPADJ8i /mVxeshti2fqRZAUxwwrEDUCGM7UVJu+iEA069jUhG/IHMH0iEMkEp9q17L3mUfsJ0MkwyDshg7ZC c7vFR6GKhf3KwLI4fPlAjxpkH51EAo6sMFSQxBAULO6eVXJTlJgcyN0OH5Tr1dkLjuTzWyJacWLOo qKAMDT47RjnKBhe1K0vbye8jjMrs21uxnGF4DCvtFbBFHYx0pqz8X2/sRy5qt0OrGwFbfWONyD/Zc jJc2uB9/XZh26ua+2IdjQR3WhhFVQH55XBZozGPHgfrXPrX/i6844mvoKut/51UTUylyZ4nALLOb4 6ssHIa6A==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLqi1-00A9FE-Rh; Thu, 02 Sep 2021 17:41:05 +0000 From: Luis Chamberlain To: axboe@kernel.dk, gregkh@linuxfoundation.org, chaitanya.kulkarni@wdc.com, atulgopinathan@gmail.com, hare@suse.de, maximlevitsky@gmail.com, oakad@yahoo.com, ulf.hansson@linaro.org, colin.king@canonical.com, shubhankarvk@gmail.com, baijiaju1990@gmail.com, trix@redhat.com, dongsheng.yang@easystack.cn, ceph-devel@vger.kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, borntraeger@de.ibm.com, oberpar@linux.ibm.com, tj@kernel.org Cc: linux-s390@vger.kernel.org, linux-mtd@lists.infradead.org, linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 2/9] ms_block: add error handling support for add_disk() Date: Thu, 2 Sep 2021 10:40:58 -0700 Message-Id: <20210902174105.2418771-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902174105.2418771-1-mcgrof@kernel.org> References: <20210902174105.2418771-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. Contrary to the typical removal which delays the put_disk() until later, since we are failing on a probe we immediately put the disk on failure from add_disk by using blk_cleanup_disk(). Signed-off-by: Luis Chamberlain --- drivers/memstick/core/ms_block.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c index 4a4573fa7b0f..86c626933c1a 100644 --- a/drivers/memstick/core/ms_block.c +++ b/drivers/memstick/core/ms_block.c @@ -2156,10 +2156,14 @@ static int msb_init_disk(struct memstick_dev *card) set_disk_ro(msb->disk, 1); msb_start(card); - device_add_disk(&card->dev, msb->disk, NULL); + rc = device_add_disk(&card->dev, msb->disk, NULL); + if (rc) + goto out_cleanup_disk; dbg("Disk added"); return 0; +out_cleanup_disk: + blk_cleanup_disk(msb->disk); out_free_tag_set: blk_mq_free_tag_set(&msb->tag_set); out_release_id: -- 2.30.2