]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[SCSI] mpt2sas: Before removing sas_device search device in list for _scsih_sas_devic...
authorKashyap, Desai <kashyap.desai@lsi.com>
Thu, 8 Apr 2010 12:25:22 +0000 (17:55 +0530)
committerJames Bottomley <James.Bottomley@suse.de>
Sun, 11 Apr 2010 19:00:32 +0000 (14:00 -0500)
Fix a oops in _scsih_sas_device_remove.  The driver was attempting to
delete a object from the sas_device link list when the object was not
present.

Added sanity check for sas_device NULL dereference.
before deleting sas_device now driver will search device in list then
only it will follow device removal.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/mpt2sas/mpt2sas_scsih.c

index 77163bad75f924340276cc50ff032bbaad8644a6..c5ff26a2a51d91b5da1cc50b892af8467f2d3b5d 100644 (file)
@@ -537,10 +537,15 @@ _scsih_sas_device_remove(struct MPT2SAS_ADAPTER *ioc,
 {
        unsigned long flags;
 
+       if (!sas_device)
+               return;
+
        spin_lock_irqsave(&ioc->sas_device_lock, flags);
-       list_del(&sas_device->list);
-       memset(sas_device, 0, sizeof(struct _sas_device));
-       kfree(sas_device);
+       if (mpt2sas_scsih_sas_device_find_by_sas_address(ioc,
+           sas_device->sas_address)) {
+               list_del(&sas_device->list);
+               kfree(sas_device);
+       }
        spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
 }