diff options
author | Dan Carpenter <error27@gmail.com> | 2010-04-23 08:01:04 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-05-02 11:04:23 -0400 |
commit | 2471b894068ec59ab3012e788401b345ef459e49 (patch) | |
tree | 09a540d9c6f5b0c7e2bd80ad12f3b6864e7d142d /drivers/scsi/pm8001 | |
parent | daa142d1773dd3a986f02a8a4da929608d24daaa (diff) |
[SCSI] pm8001: potential null dereference in pm8001_dev_gone_notify()
In the original code we dereferenced "pm8001_dev" before checking if it
was null. This patch moves the dereference inside the condition.
This was found by a static checker (smatch). I looked, but I couldn't
tell if "pm8001_dev" dev was ever actually null. The approach in this
patch seemed like the safest response.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Jack Wang <jack_wang@usish.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/pm8001')
-rw-r--r-- | drivers/scsi/pm8001/pm8001_sas.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index bff4f5139b9c..cd02ceaf67ff 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c | |||
@@ -885,11 +885,13 @@ static void pm8001_dev_gone_notify(struct domain_device *dev) | |||
885 | u32 tag; | 885 | u32 tag; |
886 | struct pm8001_hba_info *pm8001_ha; | 886 | struct pm8001_hba_info *pm8001_ha; |
887 | struct pm8001_device *pm8001_dev = dev->lldd_dev; | 887 | struct pm8001_device *pm8001_dev = dev->lldd_dev; |
888 | u32 device_id = pm8001_dev->device_id; | 888 | |
889 | pm8001_ha = pm8001_find_ha_by_dev(dev); | 889 | pm8001_ha = pm8001_find_ha_by_dev(dev); |
890 | spin_lock_irqsave(&pm8001_ha->lock, flags); | 890 | spin_lock_irqsave(&pm8001_ha->lock, flags); |
891 | pm8001_tag_alloc(pm8001_ha, &tag); | 891 | pm8001_tag_alloc(pm8001_ha, &tag); |
892 | if (pm8001_dev) { | 892 | if (pm8001_dev) { |
893 | u32 device_id = pm8001_dev->device_id; | ||
894 | |||
893 | PM8001_DISC_DBG(pm8001_ha, | 895 | PM8001_DISC_DBG(pm8001_ha, |
894 | pm8001_printk("found dev[%d:%x] is gone.\n", | 896 | pm8001_printk("found dev[%d:%x] is gone.\n", |
895 | pm8001_dev->device_id, pm8001_dev->dev_type)); | 897 | pm8001_dev->device_id, pm8001_dev->dev_type)); |