aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/mpt2sas
diff options
context:
space:
mode:
authornagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com>2012-03-20 02:40:01 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-04-23 14:27:50 -0400
commite42fafc25fa86c61824e8d4c5e7582316415d24f (patch)
tree835e4e9d649f5853606dbdd3a2f804f83d77c8f1 /drivers/scsi/mpt2sas
parent39af7a98946a73f2e4bfb35cfbca2114366d0c82 (diff)
[SCSI] mpt2sas: Fix for panic happening because of improper memory allocation
The ioc->pfacts member in the IOC structure is getting set to zero following a call to _base_get_ioc_facts due to the memset in that routine. So if the ioc->pfacts was read after a host reset, there would be a NULL pointer dereference. The routine _base_get_ioc_facts is called from context of host reset. The problem in _base_get_ioc_facts is the size of Mpi2IOCFactsReply is 64, whereas the sizeof "struct mpt2sas_facts" is 60, so there is a four byte overflow resulting from the memset. Also, there is memset in _base_get_port_facts using the incorrect structure, it should be "struct mpt2sas_port_facts" instead of Mpi2PortFactsReply. Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com> CC: stable@vger.kernel.org Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/mpt2sas')
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 702faf67710a..6102ef2cb2d8 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -3350,7 +3350,7 @@ _base_get_port_facts(struct MPT2SAS_ADAPTER *ioc, int port, int sleep_flag)
3350 } 3350 }
3351 3351
3352 pfacts = &ioc->pfacts[port]; 3352 pfacts = &ioc->pfacts[port];
3353 memset(pfacts, 0, sizeof(Mpi2PortFactsReply_t)); 3353 memset(pfacts, 0, sizeof(struct mpt2sas_port_facts));
3354 pfacts->PortNumber = mpi_reply.PortNumber; 3354 pfacts->PortNumber = mpi_reply.PortNumber;
3355 pfacts->VP_ID = mpi_reply.VP_ID; 3355 pfacts->VP_ID = mpi_reply.VP_ID;
3356 pfacts->VF_ID = mpi_reply.VF_ID; 3356 pfacts->VF_ID = mpi_reply.VF_ID;
@@ -3392,7 +3392,7 @@ _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3392 } 3392 }
3393 3393
3394 facts = &ioc->facts; 3394 facts = &ioc->facts;
3395 memset(facts, 0, sizeof(Mpi2IOCFactsReply_t)); 3395 memset(facts, 0, sizeof(struct mpt2sas_facts));
3396 facts->MsgVersion = le16_to_cpu(mpi_reply.MsgVersion); 3396 facts->MsgVersion = le16_to_cpu(mpi_reply.MsgVersion);
3397 facts->HeaderVersion = le16_to_cpu(mpi_reply.HeaderVersion); 3397 facts->HeaderVersion = le16_to_cpu(mpi_reply.HeaderVersion);
3398 facts->VP_ID = mpi_reply.VP_ID; 3398 facts->VP_ID = mpi_reply.VP_ID;
@@ -4270,7 +4270,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
4270 goto out_free_resources; 4270 goto out_free_resources;
4271 4271
4272 ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts, 4272 ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts,
4273 sizeof(Mpi2PortFactsReply_t), GFP_KERNEL); 4273 sizeof(struct mpt2sas_port_facts), GFP_KERNEL);
4274 if (!ioc->pfacts) { 4274 if (!ioc->pfacts) {
4275 r = -ENOMEM; 4275 r = -ENOMEM;
4276 goto out_free_resources; 4276 goto out_free_resources;