lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y1wcvS0ZI3acUGcF@nvidia.com>
Date:   Fri, 28 Oct 2022 15:17:33 -0300
From:   Jason Gunthorpe <jgg@...dia.com>
To:     Haoyue Xu <xuhaoyue1@...ilicon.com>
Cc:     leon@...nel.org, zyjzyj2000@...il.com, linux-rdma@...r.kernel.org,
        linuxarm@...wei.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 for-next] RDMA/rxe: cleanup some error handling in
 rxe_verbs.c

On Fri, Oct 28, 2022 at 03:50:53PM +0800, Haoyue Xu wrote:
> From: Yunsheng Lin <linyunsheng@...wei.com>
> 
> Instead of 'goto and return', just return directly to
> simplify the error handling, and avoid some unnecessary
> return value check.
> 
> Signed-off-by: Yunsheng Lin <linyunsheng@...wei.com>
> Signed-off-by: Haoyue Xu <xuhaoyue1@...ilicon.com>
> ---
> Changes since v1:
> 	Rebased to fix some conflict in the patch.
> 
>  drivers/infiniband/sw/rxe/rxe_verbs.c | 80 ++++++++-------------------
>  1 file changed, 23 insertions(+), 57 deletions(-)

This is good, applied to for-next, thanks

> @@ -921,26 +894,22 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd,
>  	struct rxe_mr *mr;
>  
>  	mr = rxe_alloc(&rxe->mr_pool);
> -	if (!mr) {
> -		err = -ENOMEM;
> -		goto err2;
> -	}
> -
> +	if (!mr)
> +		return ERR_PTR(-ENOMEM);
>  
>  	rxe_get(pd);
>  	mr->ibmr.pd = ibpd;
>  
>  	err = rxe_mr_init_user(rxe, start, length, iova, access, mr);
>  	if (err)
> -		goto err3;
> +		goto err1;
>  
>  	rxe_finalize(mr);
>  
>  	return &mr->ibmr;
>  
> -err3:
> +err1:
>  	rxe_cleanup(mr);
> -err2:
>  	return ERR_PTR(err);
>  }
>  
> @@ -956,25 +925,22 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
>  		return ERR_PTR(-EINVAL);
>  
>  	mr = rxe_alloc(&rxe->mr_pool);
> -	if (!mr) {
> -		err = -ENOMEM;
> -		goto err1;
> -	}
> +	if (!mr)
> +		return ERR_PTR(-ENOMEM);
>  
>  	rxe_get(pd);
>  	mr->ibmr.pd = ibpd;
>  
>  	err = rxe_mr_init_fast(max_num_sg, mr);
>  	if (err)
> -		goto err2;
> +		goto err1;
>  
>  	rxe_finalize(mr);
>  
>  	return &mr->ibmr;
>  
> -err2:
> -	rxe_cleanup(mr);
>  err1:
> +	rxe_cleanup(mr);
>  	return ERR_PTR(err);
>  }
>  

I fixed these two err1 labels though, do not use the errN format. I
changed them both to err_cleanup

Thanks,
Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ