Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp3318141pxb; Mon, 6 Sep 2021 18:40:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxsCj+va/JfAVNL+9knCgPUXl/NgVIdQ2E6CU071Hg3WhqF8/+MSYbTlTf698CB0yFLweC X-Received: by 2002:a92:d0cc:: with SMTP id y12mr10412816ila.38.1630978828364; Mon, 06 Sep 2021 18:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630978828; cv=none; d=google.com; s=arc-20160816; b=rSqP2i3VFNQVhWLY7SBsriuGHMszTXM1QcLl6TIs9JWyZ1Oz9z3j+dRWRCAIpO7D/4 sNj8yOStSciokgFzVdsVYXyu1DMQoqh3xEeXjka7qtdjja0lwrqPUQTG7MEwRxTJEk4t HRNEPRe6foGKwGTh/cE0Shr/iuuZ7iqQM2qREPxzVTj4ik1ti+s9M7+eljKVJReO1psq YPtabVP0GUv60xA5h1yiTOvBOSCyLQ1ggl02XUKetC5f3/A06GXhvh8e1XMc576o0fDO 1b/7kGhutk8i1AGouOyJ4isakbomK5z7jnLBt+4ufbv+t0/N7O2HT3UVGKXCHG/O2mfi /fYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LD4HmvA+6ng2SFaOBQkrpmMcYGijXFYTWjOibY469rU=; b=vs7KIaT5Z494PPbpuu0bUqroL94LKPDr/Di102F6rnwwUN312FTJUaMStUeIk5wzi4 /exYx+yPQ4Ql90fdVjKoosQBchPcB4x/fxTNSp+GasbJ/8g0v2O0niyPvJZViHcDx1Cu BhNhmcRa4zHdBhJqaN3rlHNm4HpYthId/kAY9oEKsDtYhqEN87FPJVB8okBilgW4Vrp1 JJEOzxYTWAp6ATtDh/yqmVvBuoo0sSneF1tiRBOGtBMAm8BYIKJObF6hriGGHsQ9+rIh nbkJDOROgoqxvmg6SSXFqgIb5LMu22DRJ3EfBGEWRki33LXap0l9g2Luopfzhhu68+N2 woIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GRrcgups; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si9766557ilj.16.2021.09.06.18.40.15; Mon, 06 Sep 2021 18:40:28 -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=@redhat.com header.s=mimecast20190719 header.b=GRrcgups; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237857AbhIGBim (ORCPT + 99 others); Mon, 6 Sep 2021 21:38:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29856 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232664AbhIGBij (ORCPT ); Mon, 6 Sep 2021 21:38:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630978653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LD4HmvA+6ng2SFaOBQkrpmMcYGijXFYTWjOibY469rU=; b=GRrcgupssVywBzH5KljwoqxgVpkvxMg0ydRW5LvLE/qeyWB8zj9HhFmsRbiK8CsFCTCWjI II4nAhmIPfcIbqEbbncVR8od40OvN94r8u7eHPRme6OMvD3E+QxDyp/9d2eM/v1XwId4YB BS0KdBzsR9yuf1DI0ui2oaB6/LJj46M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-420-jemrBUYpPzmuqg88LXk5sw-1; Mon, 06 Sep 2021 21:37:30 -0400 X-MC-Unique: jemrBUYpPzmuqg88LXk5sw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFBFF10054F6; Tue, 7 Sep 2021 01:37:27 +0000 (UTC) Received: from T590 (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8619927097; Tue, 7 Sep 2021 01:37:04 +0000 (UTC) Date: Tue, 7 Sep 2021 09:37:05 +0800 From: Ming Lei To: Luis Chamberlain 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: <20210830212538.148729-3-mcgrof@kernel.org> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks, Ming