| .. | .. |
|---|
| 670 | 670 | goto out_fail; |
|---|
| 671 | 671 | } |
|---|
| 672 | 672 | port = sas_port_alloc_num(sas_node->parent_dev); |
|---|
| 673 | | - if ((sas_port_add(port))) { |
|---|
| 673 | + if (!port || (sas_port_add(port))) { |
|---|
| 674 | 674 | ioc_err(ioc, "failure at %s:%d/%s()!\n", |
|---|
| 675 | 675 | __FILE__, __LINE__, __func__); |
|---|
| 676 | 676 | goto out_fail; |
|---|
| .. | .. |
|---|
| 695 | 695 | rphy = sas_expander_alloc(port, |
|---|
| 696 | 696 | mpt3sas_port->remote_identify.device_type); |
|---|
| 697 | 697 | |
|---|
| 698 | + if (!rphy) { |
|---|
| 699 | + ioc_err(ioc, "failure at %s:%d/%s()!\n", |
|---|
| 700 | + __FILE__, __LINE__, __func__); |
|---|
| 701 | + goto out_delete_port; |
|---|
| 702 | + } |
|---|
| 703 | + |
|---|
| 698 | 704 | rphy->identify = mpt3sas_port->remote_identify; |
|---|
| 699 | 705 | |
|---|
| 700 | 706 | if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { |
|---|
| .. | .. |
|---|
| 712 | 718 | if ((sas_rphy_add(rphy))) { |
|---|
| 713 | 719 | ioc_err(ioc, "failure at %s:%d/%s()!\n", |
|---|
| 714 | 720 | __FILE__, __LINE__, __func__); |
|---|
| 721 | + sas_rphy_free(rphy); |
|---|
| 722 | + rphy = NULL; |
|---|
| 723 | + goto out_delete_port; |
|---|
| 715 | 724 | } |
|---|
| 716 | 725 | |
|---|
| 717 | 726 | if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { |
|---|
| .. | .. |
|---|
| 738 | 747 | rphy_to_expander_device(rphy)); |
|---|
| 739 | 748 | return mpt3sas_port; |
|---|
| 740 | 749 | |
|---|
| 741 | | - out_fail: |
|---|
| 750 | +out_delete_port: |
|---|
| 751 | + sas_port_delete(port); |
|---|
| 752 | + |
|---|
| 753 | +out_fail: |
|---|
| 742 | 754 | list_for_each_entry_safe(mpt3sas_phy, next, &mpt3sas_port->phy_list, |
|---|
| 743 | 755 | port_siblings) |
|---|
| 744 | 756 | list_del(&mpt3sas_phy->port_siblings); |
|---|