Commit b41c09d1 authored by Kashyap, Desai's avatar Kashyap, Desai Committed by James Bottomley

[SCSI] mpt2sas: Sanity check for phy count is added using max phy count

Fix oops loading driver when there is direct attached
SEP device

The driver set max phys count to the value reported in sas iounit page
zero.  However this page doesn't take into account additional virutal
phys.  When sas topology event arrives, the phy count is larger than
expected, and the driver accesses memory array beyond the end of
allocated space, then oops.  Manufacturing page 8 contains the info
on direct attached phys.

For this fix will making sure that sas topology event is not
processing phys greater than the expected phy count.
Signed-off-by: default avatarKashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent a93c6b45
...@@ -4796,7 +4796,7 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, ...@@ -4796,7 +4796,7 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc,
int i; int i;
u16 parent_handle, handle; u16 parent_handle, handle;
u16 reason_code; u16 reason_code;
u8 phy_number; u8 phy_number, max_phys;
struct _sas_node *sas_expander; struct _sas_node *sas_expander;
struct _sas_device *sas_device; struct _sas_device *sas_device;
u64 sas_address; u64 sas_address;
...@@ -4834,11 +4834,13 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, ...@@ -4834,11 +4834,13 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc,
sas_expander = mpt2sas_scsih_expander_find_by_handle(ioc, sas_expander = mpt2sas_scsih_expander_find_by_handle(ioc,
parent_handle); parent_handle);
spin_unlock_irqrestore(&ioc->sas_node_lock, flags); spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
if (sas_expander) if (sas_expander) {
sas_address = sas_expander->sas_address; sas_address = sas_expander->sas_address;
else if (parent_handle < ioc->sas_hba.num_phys) max_phys = sas_expander->num_phys;
} else if (parent_handle < ioc->sas_hba.num_phys) {
sas_address = ioc->sas_hba.sas_address; sas_address = ioc->sas_hba.sas_address;
else max_phys = ioc->sas_hba.num_phys;
} else
return; return;
/* handle siblings events */ /* handle siblings events */
...@@ -4852,6 +4854,8 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, ...@@ -4852,6 +4854,8 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc,
ioc->pci_error_recovery) ioc->pci_error_recovery)
return; return;
phy_number = event_data->StartPhyNum + i; phy_number = event_data->StartPhyNum + i;
if (phy_number >= max_phys)
continue;
reason_code = event_data->PHY[i].PhyStatus & reason_code = event_data->PHY[i].PhyStatus &
MPI2_EVENT_SAS_TOPO_RC_MASK; MPI2_EVENT_SAS_TOPO_RC_MASK;
if ((event_data->PHY[i].PhyStatus & if ((event_data->PHY[i].PhyStatus &
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment