diff mbox

IB/mlx5: Fix an error code in __mlx5_ib_modify_qp()

Message ID 20180306100031.GB10474@mwanda (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show

Commit Message

Dan Carpenter March 6, 2018, 10 a.m. UTC
"err" is either zero or possibly uninitialized here.  It should be
-EINVAL.

Fixes: 427c1e7bcd7e ("{IB, net}/mlx5: Move the modify QP operation table to mlx5_ib")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
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

Leon Romanovsky March 6, 2018, 10:20 a.m. UTC | #1
On Tue, Mar 06, 2018 at 01:00:31PM +0300, Dan Carpenter wrote:
> "err" is either zero or possibly uninitialized here.  It should be
> -EINVAL.
>
> Fixes: 427c1e7bcd7e ("{IB, net}/mlx5: Move the modify QP operation table to mlx5_ib")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
> index 90bb96292fc4..f9a1174ad7fa 100644
> --- a/drivers/infiniband/hw/mlx5/qp.c
> +++ b/drivers/infiniband/hw/mlx5/qp.c
> @@ -3118,8 +3118,10 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
>  	mlx5_new = to_mlx5_state(new_state);
>
>  	if (mlx5_cur >= MLX5_QP_NUM_STATE || mlx5_new >= MLX5_QP_NUM_STATE ||
> -	    !optab[mlx5_cur][mlx5_new])
> +	    !optab[mlx5_cur][mlx5_new]) {
> +		err = -EINVAL;
>  		goto out;
> +	}
>

Thanks Dan,
Acked-by: Leon Romanovsky <leonro@mellanox.com>
Jason Gunthorpe March 7, 2018, 3:20 a.m. UTC | #2
On Tue, Mar 06, 2018 at 01:00:31PM +0300, Dan Carpenter wrote:
> "err" is either zero or possibly uninitialized here.  It should be
> -EINVAL.
> 
> Fixes: 427c1e7bcd7e ("{IB, net}/mlx5: Move the modify QP operation table to mlx5_ib")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Leon Romanovsky <leonro@mellanox.com>
> 
> diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
> index 90bb96292fc4..f9a1174ad7fa 100644
> +++ b/drivers/infiniband/hw/mlx5/qp.c
> @@ -3118,8 +3118,10 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
>  	mlx5_new = to_mlx5_state(new_state);
>  
>  	if (mlx5_cur >= MLX5_QP_NUM_STATE || mlx5_new >= MLX5_QP_NUM_STATE ||
> -	    !optab[mlx5_cur][mlx5_new])
> +	    !optab[mlx5_cur][mlx5_new]) {
> +		err = -EINVAL;
>  		goto out;
> +	}
>  
>  	op = optab[mlx5_cur][mlx5_new];
>  	optpar = ib_mask_to_mlx5_opt(attr_mask);

I applied this by hand to for-rc due to context changes

Thanks,
Jason
--
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/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 90bb96292fc4..f9a1174ad7fa 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -3118,8 +3118,10 @@  static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
 	mlx5_new = to_mlx5_state(new_state);
 
 	if (mlx5_cur >= MLX5_QP_NUM_STATE || mlx5_new >= MLX5_QP_NUM_STATE ||
-	    !optab[mlx5_cur][mlx5_new])
+	    !optab[mlx5_cur][mlx5_new]) {
+		err = -EINVAL;
 		goto out;
+	}
 
 	op = optab[mlx5_cur][mlx5_new];
 	optpar = ib_mask_to_mlx5_opt(attr_mask);