From: Bart Van Assche Date: Thu, 30 Mar 2017 17:17:17 +0000 (+0000) Subject: scsi: osd_uld: Check scsi_device_get() return value X-Git-Tag: v4.12-rc1~99^2~83 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c02465fa13b6232db664c5dcfe9c429b4fe31c99;p=platform%2Fkernel%2Flinux-exynos.git scsi: osd_uld: Check scsi_device_get() return value scsi_device_get() can fail. Hence check its return value. Signed-off-by: Bart Van Assche Cc: Boaz Harrosh Acked-by: Boaz Harrosh Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c index c3563a9..ed94802 100644 --- a/drivers/scsi/osd/osd_uld.c +++ b/drivers/scsi/osd/osd_uld.c @@ -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);