diff options
author | Kashyap, Desai <kashyap.desai@lsi.com> | 2010-04-08 08:25:22 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-04-11 15:00:32 -0400 |
commit | 980ead3180233d09ad37aacd803059b3142c7863 (patch) | |
tree | f5d948b5a791b0fdaf6ec9b34682157a54dcd799 /drivers/scsi/mpt2sas | |
parent | 130b958a5dbf0fca361beef5713715a2eba6529f (diff) |
[SCSI] mpt2sas: Before removing sas_device search device in list for _scsih_sas_device_remove
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>
Diffstat (limited to 'drivers/scsi/mpt2sas')
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_scsih.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index 77163bad75f9..c5ff26a2a51d 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c | |||
@@ -537,10 +537,15 @@ _scsih_sas_device_remove(struct MPT2SAS_ADAPTER *ioc, | |||
537 | { | 537 | { |
538 | unsigned long flags; | 538 | unsigned long flags; |
539 | 539 | ||
540 | if (!sas_device) | ||
541 | return; | ||
542 | |||
540 | spin_lock_irqsave(&ioc->sas_device_lock, flags); | 543 | spin_lock_irqsave(&ioc->sas_device_lock, flags); |
541 | list_del(&sas_device->list); | 544 | if (mpt2sas_scsih_sas_device_find_by_sas_address(ioc, |
542 | memset(sas_device, 0, sizeof(struct _sas_device)); | 545 | sas_device->sas_address)) { |
543 | kfree(sas_device); | 546 | list_del(&sas_device->list); |
547 | kfree(sas_device); | ||
548 | } | ||
544 | spin_unlock_irqrestore(&ioc->sas_device_lock, flags); | 549 | spin_unlock_irqrestore(&ioc->sas_device_lock, flags); |
545 | } | 550 | } |
546 | 551 | ||