]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.19/0020-mpt2sas-Fix-for-panic-happening-because-of-improper-.patch
linux-ti33x-psp 3.2: update to 3.2.21, add libertas fixes
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.19 / 0020-mpt2sas-Fix-for-panic-happening-because-of-improper-.patch
1 From b12bc1d8337657ea79d90aecba397eaee36d10f6 Mon Sep 17 00:00:00 2001
2 From: "nagalakshmi.nandigama@lsi.com" <nagalakshmi.nandigama@lsi.com>
3 Date: Tue, 20 Mar 2012 12:10:01 +0530
4 Subject: [PATCH 020/117] mpt2sas: Fix for panic happening because of improper
5  memory allocation
7 commit e42fafc25fa86c61824e8d4c5e7582316415d24f upstream.
9 The ioc->pfacts member in the IOC structure is getting set to zero
10 following a call to _base_get_ioc_facts due to the memset in that routine.
11 So if the ioc->pfacts was read after a host reset, there would be a NULL
12 pointer dereference. The routine _base_get_ioc_facts is called from context
13 of host reset.  The problem in _base_get_ioc_facts  is the size of
14 Mpi2IOCFactsReply is 64, whereas the sizeof "struct mpt2sas_facts" is 60,
15 so there is a four byte overflow resulting from the memset.
17 Also, there is memset in _base_get_port_facts using the incorrect structure,
18 it should be "struct mpt2sas_port_facts" instead of Mpi2PortFactsReply.
20 Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
21 Signed-off-by: James Bottomley <JBottomley@Parallels.com>
22 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
23 ---
24  drivers/scsi/mpt2sas/mpt2sas_base.c |    6 +++---
25  1 file changed, 3 insertions(+), 3 deletions(-)
27 diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
28 index b1ddfef..ac336e1 100644
29 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c
30 +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
31 @@ -3274,7 +3274,7 @@ _base_get_port_facts(struct MPT2SAS_ADAPTER *ioc, int port, int sleep_flag)
32         }
33  
34         pfacts = &ioc->pfacts[port];
35 -       memset(pfacts, 0, sizeof(Mpi2PortFactsReply_t));
36 +       memset(pfacts, 0, sizeof(struct mpt2sas_port_facts));
37         pfacts->PortNumber = mpi_reply.PortNumber;
38         pfacts->VP_ID = mpi_reply.VP_ID;
39         pfacts->VF_ID = mpi_reply.VF_ID;
40 @@ -3316,7 +3316,7 @@ _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
41         }
42  
43         facts = &ioc->facts;
44 -       memset(facts, 0, sizeof(Mpi2IOCFactsReply_t));
45 +       memset(facts, 0, sizeof(struct mpt2sas_facts));
46         facts->MsgVersion = le16_to_cpu(mpi_reply.MsgVersion);
47         facts->HeaderVersion = le16_to_cpu(mpi_reply.HeaderVersion);
48         facts->VP_ID = mpi_reply.VP_ID;
49 @@ -4193,7 +4193,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
50                 goto out_free_resources;
51  
52         ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts,
53 -           sizeof(Mpi2PortFactsReply_t), GFP_KERNEL);
54 +           sizeof(struct mpt2sas_port_facts), GFP_KERNEL);
55         if (!ioc->pfacts) {
56                 r = -ENOMEM;
57                 goto out_free_resources;
58 -- 
59 1.7.9.5