linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Cc: jgg@nvidia.com, Dean Luick <dean.luick@cornelisnetworks.com>,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-rc 1/6] IB/hfi1: Restore allocated resources on failed copyout
Date: Tue, 10 Jan 2023 12:12:12 +0200	[thread overview]
Message-ID: <Y705/CVFALoW1j3X@unreal> (raw)
In-Reply-To: <167328546603.1472310.17312024395730671459.stgit@awfm-02.cornelisnetworks.com>

On Mon, Jan 09, 2023 at 12:31:06PM -0500, Dennis Dalessandro wrote:
> From: Dean Luick <dean.luick@cornelisnetworks.com>
> 
> Fix a resource leak if an error occurs.
> 
> Fixes: f404ca4c7ea8 ("IB/hfi1: Refactor hfi_user_exp_rcv_setup() IOCTL")
> Signed-off-by: Dean Luick <dean.luick@cornelisnetworks.com>
> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
> ---
>  drivers/infiniband/hw/hfi1/file_ops.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
> index f5f9269fdc16..c9fc913db00c 100644
> --- a/drivers/infiniband/hw/hfi1/file_ops.c
> +++ b/drivers/infiniband/hw/hfi1/file_ops.c
> @@ -1318,12 +1318,15 @@ static int user_exp_rcv_setup(struct hfi1_filedata *fd, unsigned long arg,
>  		addr = arg + offsetof(struct hfi1_tid_info, tidcnt);
>  		if (copy_to_user((void __user *)addr, &tinfo.tidcnt,
>  				 sizeof(tinfo.tidcnt)))
> -			return -EFAULT;
> +			ret = -EFAULT;

I don't think that it is right to continue to next copy_to_user() if
first one failed.

Thanks

>  
>  		addr = arg + offsetof(struct hfi1_tid_info, length);
>  		if (copy_to_user((void __user *)addr, &tinfo.length,
>  				 sizeof(tinfo.length)))
>  			ret = -EFAULT;
> +
> +		if (ret)
> +			hfi1_user_exp_rcv_invalid(fd, &tinfo);
>  	}
>  
>  	return ret;
> 
> 

  reply	other threads:[~2023-01-10 10:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 17:31 [PATCH for-rc 0/6] HFI fixups around expected recv Dennis Dalessandro
2023-01-09 17:31 ` [PATCH for-rc 1/6] IB/hfi1: Restore allocated resources on failed copyout Dennis Dalessandro
2023-01-10 10:12   ` Leon Romanovsky [this message]
2023-01-09 17:31 ` [PATCH for-rc 2/6] IB/hfi1: Reject a zero-length user expected buffer Dennis Dalessandro
2023-01-09 17:31 ` [PATCH for-rc 3/6] IB/hfi1: Reserve user expected TIDs Dennis Dalessandro
2023-01-09 17:31 ` [PATCH for-rc 4/6] IB/hfi1: Fix expected receive setup error exit issues Dennis Dalessandro
2023-01-09 17:31 ` [PATCH for-rc 5/6] IB/hfi1: Immediately remove invalid memory from hardware Dennis Dalessandro
2023-01-09 17:31 ` [PATCH for-rc 6/6] IB/hfi1: Remove user expected buffer invalidate race Dennis Dalessandro
2023-01-16 15:41   ` Jason Gunthorpe
2023-01-17 19:19     ` Dean Luick
2023-01-18 12:42       ` Jason Gunthorpe
2023-01-19 16:00         ` Dean Luick
2023-01-19 18:05           ` Jason Gunthorpe
2023-01-20 16:09             ` Dean Luick
2023-01-10 10:17 ` [PATCH for-rc 0/6] HFI fixups around expected recv Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y705/CVFALoW1j3X@unreal \
    --to=leon@kernel.org \
    --cc=dean.luick@cornelisnetworks.com \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).