[PATCH] SCSI: Delete unnecessary checks before the function call "put_device"

From: SF Markus Elfring
Date: Wed Jun 24 2015 - 13:29:10 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Jun 2015 19:24:01 +0200

The put_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/scsi/hosts.c | 4 +---
drivers/scsi/scsi_sysfs.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 8bb173e..84c8565 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -336,9 +336,7 @@ static void scsi_host_dev_release(struct device *dev)
}

kfree(shost->shost_data);
-
- if (parent)
- put_device(parent);
+ put_device(parent);
kfree(shost);
}

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 1ac38e7..9ed5391 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -425,9 +425,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
kfree(sdev->vpd_pg80);
kfree(sdev->inquiry);
kfree(sdev);
-
- if (parent)
- put_device(parent);
+ put_device(parent);
}

static void scsi_device_dev_release(struct device *dev)
--
2.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/