diff mbox

[-next] IB/cm: Fix missing unlock on error in cm_init_qp_rtr_attr()

Message ID CAPgLHd92QCSZmjtgO9216MbD2b_i40nwzU_=fwx5-aeB=YvumQ@mail.gmail.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Wei Yongjun Jan. 16, 2014, 8:28 a.m. UTC
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Add the missing unlock before return from function cm_init_qp_rtr_attr()
in the error handling case.

Fixes: dd5f03beb4f7 ('IB/core: Ethernet L2 attributes in verbs/cm structures')
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/infiniband/core/cm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Matan Barak Jan. 16, 2014, 11:27 a.m. UTC | #1
On 16/1/2014 10:28 AM, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Add the missing unlock before return from function cm_init_qp_rtr_attr()
> in the error handling case.
>
> Fixes: dd5f03beb4f7 ('IB/core: Ethernet L2 attributes in verbs/cm structures')
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
>   drivers/infiniband/core/cm.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
> index c6d543c..0601b9d 100644
> --- a/drivers/infiniband/core/cm.c
> +++ b/drivers/infiniband/core/cm.c
> @@ -3526,8 +3526,10 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
>   		*qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU |
>   				IB_QP_DEST_QPN | IB_QP_RQ_PSN;
>   		qp_attr->ah_attr = cm_id_priv->av.ah_attr;
> -		if (!cm_id_priv->av.valid)
> +		if (!cm_id_priv->av.valid) {

Hi,

Thanks for the fix.

> +			spin_unlock_irqrestore(&cm_id_priv->lock, flags);
>   			return -EINVAL;
> +		}

Another option is to go with "goto style" error-handling. This could 
have some future benefit if this code will get more complicated 
(introducing more error flows).


>   		if (cm_id_priv->av.ah_attr.vlan_id != 0xffff) {
>   			qp_attr->vlan_id = cm_id_priv->av.ah_attr.vlan_id;
>   			*qp_attr_mask |= IB_QP_VID;
>

Regards,
Matan

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index c6d543c..0601b9d 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3526,8 +3526,10 @@  static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
 		*qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU |
 				IB_QP_DEST_QPN | IB_QP_RQ_PSN;
 		qp_attr->ah_attr = cm_id_priv->av.ah_attr;
-		if (!cm_id_priv->av.valid)
+		if (!cm_id_priv->av.valid) {
+			spin_unlock_irqrestore(&cm_id_priv->lock, flags);
 			return -EINVAL;
+		}
 		if (cm_id_priv->av.ah_attr.vlan_id != 0xffff) {
 			qp_attr->vlan_id = cm_id_priv->av.ah_attr.vlan_id;
 			*qp_attr_mask |= IB_QP_VID;