mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Mayank Suman <mayanksuman@live.com>,
	ruscur@russell.cc, oohall@gmail.com, mpe@ellerman.id.au,
	benh@kernel.crashing.org, paulus@samba.org,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arch:powerpc simple_write_to_buffer return check
Date: Fri, 5 Feb 2021 08:21:04 +0100	[thread overview]
Message-ID: <8be2b91b-cef1-ea68-836a-94c8a574d760@csgroup.eu> (raw)
In-Reply-To: <PS1PR04MB29345AB59076B370A4F99F75D6B39@PS1PR04MB2934.apcprd04.prod.outlook.com>

Please provide some description of the change.

And please clarify the patch subject, because as far as I can see, the return is already checked 
allthough the check seams wrong.

Le 04/02/2021 à 19:16, Mayank Suman a écrit :
> Signed-off-by: Mayank Suman <mayanksuman@live.com>
> ---
>   arch/powerpc/kernel/eeh.c                    | 8 ++++----
>   arch/powerpc/platforms/powernv/eeh-powernv.c | 4 ++--
>   2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
> index 813713c9120c..2dbe1558a71f 100644
> --- a/arch/powerpc/kernel/eeh.c
> +++ b/arch/powerpc/kernel/eeh.c
> @@ -1628,8 +1628,8 @@ static ssize_t eeh_force_recover_write(struct file *filp,
>   	char buf[20];
>   	int ret;
>   
> -	ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
> -	if (!ret)
> +	ret = simple_write_to_buffer(buf, sizeof(buf)-1, ppos, user_buf, count);
> +	if (ret <= 0) >   		return -EFAULT;

Why return -EFAULT when the function has returned -EINVAL ?
And why is it -EFAULT when ret is 0 ? EFAULT means error accessing memory.

>   
>   	/*
> @@ -1696,7 +1696,7 @@ static ssize_t eeh_dev_check_write(struct file *filp,
>   
>   	memset(buf, 0, sizeof(buf));
>   	ret = simple_write_to_buffer(buf, sizeof(buf)-1, ppos, user_buf, count);
> -	if (!ret)
> +	if (ret <= 0)
>   		return -EFAULT;
>   
>   	ret = sscanf(buf, "%x:%x:%x.%x", &domain, &bus, &dev, &fn);
> @@ -1836,7 +1836,7 @@ static ssize_t eeh_dev_break_write(struct file *filp,
>   
>   	memset(buf, 0, sizeof(buf));
>   	ret = simple_write_to_buffer(buf, sizeof(buf)-1, ppos, user_buf, count);
> -	if (!ret)
> +	if (ret <= 0)
>   		return -EFAULT;
>   
>   	ret = sscanf(buf, "%x:%x:%x.%x", &domain, &bus, &dev, &fn);
> diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
> index 89e22c460ebf..36ed2b8f7375 100644
> --- a/arch/powerpc/platforms/powernv/eeh-powernv.c
> +++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
> @@ -76,8 +76,8 @@ static ssize_t pnv_eeh_ei_write(struct file *filp,
>   		return -ENXIO;
>   
>   	/* Copy over argument buffer */
> -	ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
> -	if (!ret)
> +	ret = simple_write_to_buffer(buf, sizeof(buf)-1, ppos, user_buf, count);
> +	if (ret <= 0)
>   		return -EFAULT;
>   
>   	/* Retrieve parameters */
> 

  parent reply	other threads:[~2021-02-05  7:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 18:16 Mayank Suman
2021-02-04 22:35 ` Oliver O'Halloran
2021-02-05  6:13   ` Mayank Suman
2021-02-05  7:21 ` Christophe Leroy [this message]
2021-02-05  8:29   ` Mayank Suman

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=8be2b91b-cef1-ea68-836a-94c8a574d760@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mayanksuman@live.com \
    --cc=mpe@ellerman.id.au \
    --cc=oohall@gmail.com \
    --cc=paulus@samba.org \
    --cc=ruscur@russell.cc \
    /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

all inboxes | Powered by JetHome®