hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/scsi/mpt3sas/mpt3sas_transport.c
....@@ -670,7 +670,7 @@
670670 goto out_fail;
671671 }
672672 port = sas_port_alloc_num(sas_node->parent_dev);
673
- if ((sas_port_add(port))) {
673
+ if (!port || (sas_port_add(port))) {
674674 ioc_err(ioc, "failure at %s:%d/%s()!\n",
675675 __FILE__, __LINE__, __func__);
676676 goto out_fail;
....@@ -695,6 +695,12 @@
695695 rphy = sas_expander_alloc(port,
696696 mpt3sas_port->remote_identify.device_type);
697697
698
+ if (!rphy) {
699
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
700
+ __FILE__, __LINE__, __func__);
701
+ goto out_delete_port;
702
+ }
703
+
698704 rphy->identify = mpt3sas_port->remote_identify;
699705
700706 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) {
....@@ -712,6 +718,9 @@
712718 if ((sas_rphy_add(rphy))) {
713719 ioc_err(ioc, "failure at %s:%d/%s()!\n",
714720 __FILE__, __LINE__, __func__);
721
+ sas_rphy_free(rphy);
722
+ rphy = NULL;
723
+ goto out_delete_port;
715724 }
716725
717726 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) {
....@@ -738,7 +747,10 @@
738747 rphy_to_expander_device(rphy));
739748 return mpt3sas_port;
740749
741
- out_fail:
750
+out_delete_port:
751
+ sas_port_delete(port);
752
+
753
+out_fail:
742754 list_for_each_entry_safe(mpt3sas_phy, next, &mpt3sas_port->phy_list,
743755 port_siblings)
744756 list_del(&mpt3sas_phy->port_siblings);