linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: haver <haver@linux.vnet.ibm.com>
To: zhong jiang <zhongjiang@huawei.com>
Cc: gregkh@linuxfoundation.org, gpiccoli@linux.vnet.ibm.com,
	arnd@arndb.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] misc: genwqe: should return proper error value.
Date: Mon, 12 Nov 2018 12:28:12 +0100	[thread overview]
Message-ID: <19c4da1964bcc195ae3dab346e34e6b9@linux.vnet.ibm.com> (raw)
In-Reply-To: <1537410553-23836-1-git-send-email-zhongjiang@huawei.com>

On 2018-09-20 04:29, zhong jiang wrote:
> The function should return -EFAULT when copy_from_user fails. Even
> though the caller does not distinguish them. but we should keep 
> backward
> compatibility.
> 
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  drivers/misc/genwqe/card_utils.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/misc/genwqe/card_utils.c 
> b/drivers/misc/genwqe/card_utils.c
> index 8679e0b..f0961ec 100644
> --- a/drivers/misc/genwqe/card_utils.c
> +++ b/drivers/misc/genwqe/card_utils.c
> @@ -298,7 +298,7 @@ static int genwqe_sgl_size(int num_pages)
>  int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl 
> *sgl,
>  			  void __user *user_addr, size_t user_size, int write)
>  {
> -	int rc;
> +	int ret = -ENOMEM;
>  	struct pci_dev *pci_dev = cd->pci_dev;
> 
>  	sgl->fpage_offs = offset_in_page((unsigned long)user_addr);
> @@ -318,7 +318,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd,
> struct genwqe_sgl *sgl,
>  	if (get_order(sgl->sgl_size) > MAX_ORDER) {
>  		dev_err(&pci_dev->dev,
>  			"[%s] err: too much memory requested!\n", __func__);
> -		return -ENOMEM;
> +		return ret;
>  	}
> 
>  	sgl->sgl = __genwqe_alloc_consistent(cd, sgl->sgl_size,
> @@ -326,7 +326,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd,
> struct genwqe_sgl *sgl,
>  	if (sgl->sgl == NULL) {
>  		dev_err(&pci_dev->dev,
>  			"[%s] err: no memory available!\n", __func__);
> -		return -ENOMEM;
> +		return ret;
>  	}
> 
>  	/* Only use buffering on incomplete pages */
> @@ -339,7 +339,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd,
> struct genwqe_sgl *sgl,
>  		/* Sync with user memory */
>  		if (copy_from_user(sgl->fpage + sgl->fpage_offs,
>  				   user_addr, sgl->fpage_size)) {
> -			rc = -EFAULT;
> +			ret = -EFAULT;
>  			goto err_out;
>  		}
>  	}
> @@ -352,7 +352,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd,
> struct genwqe_sgl *sgl,
>  		/* Sync with user memory */
>  		if (copy_from_user(sgl->lpage, user_addr + user_size -
>  				   sgl->lpage_size, sgl->lpage_size)) {
> -			rc = -EFAULT;
> +			ret = -EFAULT;
>  			goto err_out2;
>  		}
>  	}
> @@ -374,7 +374,8 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd,
> struct genwqe_sgl *sgl,
>  	sgl->sgl = NULL;
>  	sgl->sgl_dma_addr = 0;
>  	sgl->sgl_size = 0;
> -	return -ENOMEM;
> +
> +	return ret;
>  }
> 
>  int genwqe_setup_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl,

Thanks for the contribution. Should be fine to change that and have
a more precise failure information.

Signed-off-by: Frank Haverkamp <haver@linux.vnet.ibm.com>


      reply	other threads:[~2018-11-12 11:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20  2:29 [PATCH] misc: genwqe: should return proper error value zhong jiang
2018-11-12 11:28 ` haver [this message]

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=19c4da1964bcc195ae3dab346e34e6b9@linux.vnet.ibm.com \
    --to=haver@linux.vnet.ibm.com \
    --cc=arnd@arndb.de \
    --cc=gpiccoli@linux.vnet.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhongjiang@huawei.com \
    /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).