IB/mlx4: Fix leaks in __mlx4_ib_modify_qp

Temporarily allocated struct mlx4_qp_context *context is leaked by
several error paths. The patch takes advantage of the return value
'err' being preinitialized to -EINVAL.

Spotted by Coverity (CID 1768).

Signed-off-by: Florin Malita <fmalita@gmail.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by Florin Malita and committed by Roland Dreier f5b40431 c2e68052

+5 -7
+5 -7
drivers/infiniband/hw/mlx4/qp.c
··· 742 742 if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_4096) { 743 743 printk(KERN_ERR "path MTU (%u) is invalid\n", 744 744 attr->path_mtu); 745 - return -EINVAL; 745 + goto out; 746 746 } 747 747 context->mtu_msgmax = (attr->path_mtu << 5) | 31; 748 748 } ··· 781 781 782 782 if (attr_mask & IB_QP_AV) { 783 783 if (mlx4_set_path(dev, &attr->ah_attr, &context->pri_path, 784 - attr_mask & IB_QP_PORT ? attr->port_num : qp->port)) { 785 - err = -EINVAL; 784 + attr_mask & IB_QP_PORT ? attr->port_num : qp->port)) 786 785 goto out; 787 - } 788 786 789 787 optpar |= (MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH | 790 788 MLX4_QP_OPTPAR_SCHED_QUEUE); ··· 796 798 if (attr_mask & IB_QP_ALT_PATH) { 797 799 if (attr->alt_port_num == 0 || 798 800 attr->alt_port_num > dev->dev->caps.num_ports) 799 - return -EINVAL; 801 + goto out; 800 802 801 803 if (attr->alt_pkey_index >= 802 804 dev->dev->caps.pkey_table_len[attr->alt_port_num]) 803 - return -EINVAL; 805 + goto out; 804 806 805 807 if (mlx4_set_path(dev, &attr->alt_ah_attr, &context->alt_path, 806 808 attr->alt_port_num)) 807 - return -EINVAL; 809 + goto out; 808 810 809 811 context->alt_path.pkey_index = attr->alt_pkey_index; 810 812 context->alt_path.ackto = attr->alt_timeout << 3;