aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2006-06-17 23:37:41 -0400
committerRoland Dreier <rolandd@cisco.com>2006-06-17 23:37:41 -0400
commitc9c5d9feef86debee4d8e77a738ad86877cf371a (patch)
tree692adc21d8337a063be7e159860ded87b6e6829a /drivers
parent3463175d6ee55fdbd5cda2a03415e2068599b2b7 (diff)
IB/mthca: Fix memory leak on modify_qp error paths
Some error paths after the mthca_alloc_mailbox() call in mthca_modify_qp() just do a "return -EINVAL" without freeing the mailbox. Convert these returns to "goto out" to avoid leaking the mailbox storage. Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 07c13be07a4a..322bc32a93f6 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -534,7 +534,7 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
534 struct mthca_qp_context *qp_context; 534 struct mthca_qp_context *qp_context;
535 u32 sqd_event = 0; 535 u32 sqd_event = 0;
536 u8 status; 536 u8 status;
537 int err; 537 int err = -EINVAL;
538 538
539 if (attr_mask & IB_QP_CUR_STATE) { 539 if (attr_mask & IB_QP_CUR_STATE) {
540 cur_state = attr->cur_qp_state; 540 cur_state = attr->cur_qp_state;
@@ -618,7 +618,7 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
618 if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_2048) { 618 if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_2048) {
619 mthca_dbg(dev, "path MTU (%u) is invalid\n", 619 mthca_dbg(dev, "path MTU (%u) is invalid\n",
620 attr->path_mtu); 620 attr->path_mtu);
621 return -EINVAL; 621 goto out;
622 } 622 }
623 qp_context->mtu_msgmax = (attr->path_mtu << 5) | 31; 623 qp_context->mtu_msgmax = (attr->path_mtu << 5) | 31;
624 } 624 }
@@ -672,7 +672,7 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
672 if (attr_mask & IB_QP_AV) { 672 if (attr_mask & IB_QP_AV) {
673 if (mthca_path_set(dev, &attr->ah_attr, &qp_context->pri_path, 673 if (mthca_path_set(dev, &attr->ah_attr, &qp_context->pri_path,
674 attr_mask & IB_QP_PORT ? attr->port_num : qp->port)) 674 attr_mask & IB_QP_PORT ? attr->port_num : qp->port))
675 return -EINVAL; 675 goto out;
676 676
677 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH); 677 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH);
678 } 678 }
@@ -686,18 +686,18 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
686 if (attr->alt_pkey_index >= dev->limits.pkey_table_len) { 686 if (attr->alt_pkey_index >= dev->limits.pkey_table_len) {
687 mthca_dbg(dev, "Alternate P_Key index (%u) too large. max is %d\n", 687 mthca_dbg(dev, "Alternate P_Key index (%u) too large. max is %d\n",
688 attr->alt_pkey_index, dev->limits.pkey_table_len-1); 688 attr->alt_pkey_index, dev->limits.pkey_table_len-1);
689 return -EINVAL; 689 goto out;
690 } 690 }
691 691
692 if (attr->alt_port_num == 0 || attr->alt_port_num > dev->limits.num_ports) { 692 if (attr->alt_port_num == 0 || attr->alt_port_num > dev->limits.num_ports) {
693 mthca_dbg(dev, "Alternate port number (%u) is invalid\n", 693 mthca_dbg(dev, "Alternate port number (%u) is invalid\n",
694 attr->alt_port_num); 694 attr->alt_port_num);
695 return -EINVAL; 695 goto out;
696 } 696 }
697 697
698 if (mthca_path_set(dev, &attr->alt_ah_attr, &qp_context->alt_path, 698 if (mthca_path_set(dev, &attr->alt_ah_attr, &qp_context->alt_path,
699 attr->alt_ah_attr.port_num)) 699 attr->alt_ah_attr.port_num))
700 return -EINVAL; 700 goto out;
701 701
702 qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index | 702 qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index |
703 attr->alt_port_num << 24); 703 attr->alt_port_num << 24);