Skip to content

Commit

Permalink
[SCSI] mpt2sas: Before removing sas_device search device in list for …
Browse files Browse the repository at this point in the history
…_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>
  • Loading branch information
Kashyap, Desai authored and James Bottomley committed Apr 11, 2010
1 parent 130b958 commit 980ead3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/scsi/mpt2sas/mpt2sas_scsih.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 980ead3

Please sign in to comment.