From 03b1a06203a1f283ad8a20dce78f0f5f17eaeb88 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 23 Mar 2017 13:41:42 +0300 Subject: scsi: osd_uld: remove an unneeded NULL check We don't call the remove() function unless probe() succeeds so "oud" can't be NULL here. Plus, if it were NULL, we dereference it on the next line so it would crash anyway. [mkp: applied by hand] Signed-off-by: Dan Carpenter Acked-by: Boaz Harrosh Signed-off-by: Martin K. Petersen --- drivers/scsi/osd/osd_uld.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/osd') diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c index e0ce5d2fd14d..c3563a9512b7 100644 --- a/drivers/scsi/osd/osd_uld.c +++ b/drivers/scsi/osd/osd_uld.c @@ -524,10 +524,9 @@ static int osd_remove(struct device *dev) struct scsi_device *scsi_device = to_scsi_device(dev); struct osd_uld_device *oud = dev_get_drvdata(dev); - if (!oud || (oud->od.scsi_device != scsi_device)) { - OSD_ERR("Half cooked osd-device %p,%p || %p!=%p", - dev, oud, oud ? oud->od.scsi_device : NULL, - scsi_device); + if (oud->od.scsi_device != scsi_device) { + OSD_ERR("Half cooked osd-device %p, || %p!=%p", + dev, oud->od.scsi_device, scsi_device); } device_unregister(&oud->class_dev); -- cgit From c02465fa13b6232db664c5dcfe9c429b4fe31c99 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 30 Mar 2017 17:17:17 +0000 Subject: 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 --- drivers/scsi/osd/osd_uld.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/osd') diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c index c3563a9512b7..ed948025112c 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); -- cgit