lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211015233028.2167651-2-mcgrof@kernel.org>
Date:   Fri, 15 Oct 2021 16:30:20 -0700
From:   Luis Chamberlain <mcgrof@...nel.org>
To:     axboe@...nel.dk, jejb@...ux.ibm.com, martin.petersen@...cle.com,
        agk@...hat.com, snitzer@...hat.com, colyli@...e.de,
        kent.overstreet@...il.com, boris.ostrovsky@...cle.com,
        jgross@...e.com, sstabellini@...nel.org, roger.pau@...rix.com,
        geert@...ux-m68k.org, ulf.hansson@...aro.org, tj@...nel.org,
        hare@...e.de, jdike@...toit.com, richard@....at,
        anton.ivanov@...bridgegreys.com, johannes.berg@...el.com,
        krisman@...labora.com, chris.obbard@...labora.com,
        thehajime@...il.com, zhuyifei1999@...il.com, haris.iqbal@...os.com,
        jinpu.wang@...os.com, miquel.raynal@...tlin.com, vigneshr@...com,
        linux-mtd@...ts.infradead.org
Cc:     linux-scsi@...r.kernel.org, dm-devel@...hat.com,
        linux-bcache@...r.kernel.org, xen-devel@...ts.xenproject.org,
        linux-m68k@...ts.linux-m68k.org, linux-um@...ts.infradead.org,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        Luis Chamberlain <mcgrof@...nel.org>,
        Christoph Hellwig <hch@....de>
Subject: [PATCH 1/9] scsi/sd: add error handling support for add_disk()

We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling.

As with the error handling for device_add() we follow the same
logic and just put the device so that cleanup is done via the
scsi_disk_release().

Reviewed-by: Christoph Hellwig <hch@....de>
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
 drivers/scsi/sd.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a646d27df681..d69f2e626e76 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3457,7 +3457,13 @@ static int sd_probe(struct device *dev)
 		pm_runtime_set_autosuspend_delay(dev,
 			sdp->host->hostt->rpm_autosuspend_delay);
 	}
-	device_add_disk(dev, gd, NULL);
+
+	error = device_add_disk(dev, gd, NULL);
+	if (error) {
+		put_device(&sdkp->dev);
+		goto out;
+	}
+
 	if (sdkp->capacity)
 		sd_dif_config_host(sdkp);
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ