]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
scsi: osd_uld: Check scsi_device_get() return value
authorBart Van Assche <Bart.VanAssche@sandisk.com>
Thu, 30 Mar 2017 17:17:17 +0000 (17:17 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 6 Apr 2017 16:43:12 +0000 (12:43 -0400)
scsi_device_get() can fail. Hence check its return value.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Boaz Harrosh <bharrosh@panasas.com>
Acked-by: Boaz Harrosh <ooo@electrozaur.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/osd/osd_uld.c

index c3563a9512b7ccff8d102f28cfd517b68d3a7805..ed948025112cf719955a75a7d9be5ebc6b7e3ab1 100644 (file)
@@ -464,14 +464,15 @@ static int osd_probe(struct device *dev)
        /* hold one more reference to the scsi_device that will get released
         * in __release, in case a logout is happening while fs is mounted
         */
-       scsi_device_get(scsi_device);
+       if (scsi_device_get(scsi_device))
+               goto err_put_disk;
        osd_dev_init(&oud->od, scsi_device);
 
        /* Detect the OSD Version */
        error = __detect_osd(oud);
        if (error) {
                OSD_ERR("osd detection failed, non-compatible OSD device\n");
-               goto err_put_disk;
+               goto err_put_sdev;
        }
 
        /* init the char-device for communication with user-mode */
@@ -508,8 +509,9 @@ static int osd_probe(struct device *dev)
 
 err_put_cdev:
        cdev_del(&oud->cdev);
-err_put_disk:
+err_put_sdev:
        scsi_device_put(scsi_device);
+err_put_disk:
        put_disk(disk);
 err_free_osd:
        dev_set_drvdata(dev, NULL);