aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Malita <fmalita@gmail.com>2007-07-19 15:58:09 -0400
committerRoland Dreier <rolandd@cisco.com>2007-07-21 00:19:43 -0400
commitf5b404317b79823ec643dfbb71d62f65a48cc178 (patch)
tree9957a904999d4bea903653499af02affa1d8b609
parentc2e68052429fdf87702fccd272951282bef1c60a (diff)
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>
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index b5a24fbef70d..5456bc4aff7c 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -742,7 +742,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
742 if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_4096) { 742 if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_4096) {
743 printk(KERN_ERR "path MTU (%u) is invalid\n", 743 printk(KERN_ERR "path MTU (%u) is invalid\n",
744 attr->path_mtu); 744 attr->path_mtu);
745 return -EINVAL; 745 goto out;
746 } 746 }
747 context->mtu_msgmax = (attr->path_mtu << 5) | 31; 747 context->mtu_msgmax = (attr->path_mtu << 5) | 31;
748 } 748 }
@@ -781,10 +781,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
781 781
782 if (attr_mask & IB_QP_AV) { 782 if (attr_mask & IB_QP_AV) {
783 if (mlx4_set_path(dev, &attr->ah_attr, &context->pri_path, 783 if (mlx4_set_path(dev, &attr->ah_attr, &context->pri_path,
784 attr_mask & IB_QP_PORT ? attr->port_num : qp->port)) { 784 attr_mask & IB_QP_PORT ? attr->port_num : qp->port))
785 err = -EINVAL;
786 goto out; 785 goto out;
787 }
788 786
789 optpar |= (MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH | 787 optpar |= (MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH |
790 MLX4_QP_OPTPAR_SCHED_QUEUE); 788 MLX4_QP_OPTPAR_SCHED_QUEUE);
@@ -798,15 +796,15 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
798 if (attr_mask & IB_QP_ALT_PATH) { 796 if (attr_mask & IB_QP_ALT_PATH) {
799 if (attr->alt_port_num == 0 || 797 if (attr->alt_port_num == 0 ||
800 attr->alt_port_num > dev->dev->caps.num_ports) 798 attr->alt_port_num > dev->dev->caps.num_ports)
801 return -EINVAL; 799 goto out;
802 800
803 if (attr->alt_pkey_index >= 801 if (attr->alt_pkey_index >=
804 dev->dev->caps.pkey_table_len[attr->alt_port_num]) 802 dev->dev->caps.pkey_table_len[attr->alt_port_num])
805 return -EINVAL; 803 goto out;
806 804
807 if (mlx4_set_path(dev, &attr->alt_ah_attr, &context->alt_path, 805 if (mlx4_set_path(dev, &attr->alt_ah_attr, &context->alt_path,
808 attr->alt_port_num)) 806 attr->alt_port_num))
809 return -EINVAL; 807 goto out;
810 808
811 context->alt_path.pkey_index = attr->alt_pkey_index; 809 context->alt_path.pkey_index = attr->alt_pkey_index;
812 context->alt_path.ackto = attr->alt_timeout << 3; 810 context->alt_path.ackto = attr->alt_timeout << 3;