Re: [PATCH] IB/core: Fix wrong return value in _ib_modify_qp()

From: Jason Gunthorpe
Date: Thu Aug 06 2020 - 14:29:51 EST


On Sun, Aug 02, 2020 at 07:15:42PM +0800, Tianjia Zhang wrote:
> On an error exit path, a negative error code should be returned
> instead of a positive return value.
>
> Fixes: 7a5c938b9ed09 ("IB/core: Check for rdma_protocol_ib only after validating port_num")
> Cc: Jason Gunthorpe <jgg@xxxxxxxx>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@xxxxxxxxxxxxxxxxx>
> ---
> drivers/infiniband/core/verbs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index 53d6505c0c7b..f369f0a19e85 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -1712,7 +1712,7 @@ static int _ib_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
> if (!(rdma_protocol_ib(qp->device,
> attr->alt_ah_attr.port_num) &&
> rdma_protocol_ib(qp->device, port))) {
> - ret = EINVAL;
> + ret = -EINVAL;
> goto out;
> }
> }

This was already fixed here:

commit 47fda651d5af2506deac57d54887cf55ce26e244
Author: Li Heng <liheng40@xxxxxxxxxx>
Date: Sat Jul 25 10:56:27 2020 +0800

RDMA/core: Fix return error value in _ib_modify_qp() to negative

The error codes in _ib_modify_qp() are supposed to be negative errno.

Fixes: 7a5c938b9ed0 ("IB/core: Check for rdma_protocol_ib only after validating port_num")
Link: https://lore.kernel.org/r/1595645787-20375-1-git-send-email-liheng40@xxxxxxxxxx
Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
Signed-off-by: Li Heng <liheng40@xxxxxxxxxx>
Reviewed-by: Parav Pandit <parav@xxxxxxxxxxxx>
Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Thanks,
Jason