]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mpt3sas: set num_phys after allocating phy[] space
authorJoe Lawrence <joe.lawrence@stratus.com>
Wed, 25 May 2016 19:14:28 +0000 (15:14 -0400)
committerChuck Anderson <chuck.anderson@oracle.com>
Mon, 6 Mar 2017 21:24:03 +0000 (13:24 -0800)
commit0463c8e62129cb16df78c8bf4b83cfe7d997dfd5
treeb7282fd2c0df44d5512fbc8579c36bb655c5c888
parenta85df3340dd4c045e3cc36d02de261c4936db9e0
mpt3sas: set num_phys after allocating phy[] space

Orabug: 25535122

In _scsih_sas_host_add, the number of HBA phys are determined and then
later used to allocate an array of struct _sas_phy's.  If the routine
sets ioc->sas_hba.num_phys, but then fails to allocate the
ioc->sas_hba.phy array (by kcalloc error or other intermediate
error/exit path), ioc->sas_hba is left in a dangerous state: all readers
of ioc->sas_hba.phy[] do so by indexing it from 0..ioc->sas_hba.num_phys
without checking that the space was ever allocated.

Modify _scsih_sas_host_add to set ioc->sas_hba.num_phys only after
successfully allocating ioc->sas_hba.phy[].

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 87aa95d4bb77613acaed9724efe07dde9e9bacd7)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/scsi/mpt3sas/mpt3sas_scsih.c