Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp2034535pxb; Mon, 13 Sep 2021 10:29:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1ed3R6Z39nIxTPMfgj2mVs/PvfmDiIvOzj/qMEMxbss5gKyYWyYbc/v4aOvLYppd+jgkz X-Received: by 2002:a17:906:8608:: with SMTP id o8mr13964190ejx.470.1631554147727; Mon, 13 Sep 2021 10:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631554147; cv=none; d=google.com; s=arc-20160816; b=tMq81QRPdPXw8asTgUlNIYqtDYL6Zjq5hoWR291uvOkVs3RY/JuCeu4swEDofN0mqU p7yZLxTdjMmWOk2eY5xBl3umvJGLhjVxj4x0uvv2Q1jyAvAHGAz0OclGK/NeN1tgQgsM mN8q51GU8qZJb2bKJFizgHCHqE01zCqObDZ+/eVCgYHSKwdXUyaXyW75n4jEcm9bm5Eq dx/ihPb5MwrMnMbMVU2YK1dAcVVmsf1gDUxNJlTyeojpNwHB5OdmvJFbm0oytSCKH7f3 qGj3ErYd9xQr+/YhYGJ4+EYvGK7qvBsnimGQ6DYU6kGbDyVVFh+mL+arzwVJ59XYZU07 2L9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=n6IoAZ8B/kEcoizb/4oIl8YoC6PaMi7dZ4UmJ7FfTuc=; b=a4j5ZwvdLnHyr1z3YDpAz4ETk/HYghptDmaLJJfO3S7CJFyXQc5V0W6wMfDs4X33+C ybIMI1dH2LdvLLYDXN3sKBeunnSFBPWFsmU6VYNRmGstofm0eFT2gngWPYEtAcy06XrC CM4z0yBk7hEKyhGBwucAFWvG/n1uncNzjlMebZjFURnWGgaVyYL0TZKebudRAz01K2GB xhngrCjq+/8RhcLMtd+reuay8wqX1Xi7iNNxznKYNAS3QhX+pswUbqHtlwqdfoLs6d2g V+T5F2dzpJdyUgJqdnYanYnBPekJAWsnmSAo2/jw+wYV9I1Ijo1xzQ6UHOOK5Tj5Vst4 MvVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=pK5QwDIE; 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 y18si7852673ejh.298.2021.09.13.10.28.41; Mon, 13 Sep 2021 10:29:07 -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=pK5QwDIE; 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 S240187AbhIMR1s (ORCPT + 99 others); Mon, 13 Sep 2021 13:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233121AbhIMR1r (ORCPT ); Mon, 13 Sep 2021 13:27:47 -0400 Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D25BC061574; Mon, 13 Sep 2021 10:26:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=n6IoAZ8B/kEcoizb/4oIl8YoC6PaMi7dZ4UmJ7FfTuc=; b=pK5QwDIEOUYgR3LtlFvUy5fURG 9u45mAqM1M9DAu9Zww5qGhwL7DkhW606ory3IOBDIiQw5bkR5CbNS1SnMZCioV+m24ylfkxb7A6ge 2tsX3nC1XrVrNY/xrt2K0/CbkDq4gqhlSc36DUyXHmcmx7U/KtCkShut18PHWMXO8eKaqzv2/nEDF fpmHTPjhk8b8IQe0jTE2AKFDSU3Nj0ipIbcN+0M6LFLuck79b71sJareQfNB69tQztBEyElRHIVdE YXsLWDnPX/zVc4jzgcfn3FHMudr5LNLi338cljUuC9wVwpsxEPKs0rw9FnVgbReeQCs/XMBa1XJ4b hxPQRrPQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPpib-002gGS-4q; Mon, 13 Sep 2021 17:26:09 +0000 Date: Mon, 13 Sep 2021 10:26:09 -0700 From: Luis Chamberlain To: Ming Lei Cc: 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, hch@infradead.org, hare@suse.de, bvanassche@acm.org, 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, Christoph Hellwig Subject: Re: [PATCH v3 2/8] scsi/sr: add error handling support for add_disk() Message-ID: References: <20210830212538.148729-1-mcgrof@kernel.org> <20210830212538.148729-3-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 07, 2021 at 09:37:05AM +0800, Ming Lei wrote: > On Mon, Aug 30, 2021 at 02:25:32PM -0700, Luis Chamberlain wrote: > > 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/scsi/sr.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c > > index 2942a4ec9bdd..72fd21844367 100644 > > --- a/drivers/scsi/sr.c > > +++ b/drivers/scsi/sr.c > > @@ -779,7 +779,10 @@ static int sr_probe(struct device *dev) > > dev_set_drvdata(dev, cd); > > disk->flags |= GENHD_FL_REMOVABLE; > > sr_revalidate_disk(cd); > > - device_add_disk(&sdev->sdev_gendev, disk, NULL); > > + > > + error = device_add_disk(&sdev->sdev_gendev, disk, NULL); > > + if (error) > > + goto fail_minor; > > You don't undo register_cdrom(), maybe you can use kref_put(&cd->kref, sr_kref_release); > to simplify the error handling. Works with me, thanks! Luis