mpt3sas: avoid mpt3sas_transport_port_add NULL parent_dev
authorJoe Lawrence <joe.lawrence@stratus.com>
Wed, 25 May 2016 19:14:29 +0000 (15:14 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 13 Jul 2016 03:16:31 +0000 (23:16 -0400)
If _scsih_sas_host_add's call to mpt3sas_config_get_sas_iounit_pg0
fails, ioc->sas_hba.parent_dev may be left uninitialized.  A later
device probe could invoke mpt3sas_transport_port_add which will call
sas_port_alloc_num [scsi_transport_sas] with a NULL parent_dev pointer.

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>
drivers/scsi/mpt3sas/mpt3sas_transport.c

index 6a84b82d71bb333999e1fee8cc87e40a9dc80217..ff93286bc32f0ada8e034cf69d8c0d505e3640f1 100644 (file)
@@ -705,6 +705,11 @@ mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, u16 handle,
                goto out_fail;
        }
 
+       if (!sas_node->parent_dev) {
+               pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
+                   ioc->name, __FILE__, __LINE__, __func__);
+               goto out_fail;
+       }
        port = sas_port_alloc_num(sas_node->parent_dev);
        if ((sas_port_add(port))) {
                pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",