[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <PS1PR04MB293467B694912148C8F3FE5FD6B29@PS1PR04MB2934.apcprd04.prod.outlook.com>
Date: Fri, 5 Feb 2021 13:59:15 +0530
From: Mayank Suman <mayanksuman@...e.com>
To: Christophe Leroy <christophe.leroy@...roup.eu>, ruscur@...sell.cc,
oohall@...il.com, mpe@...erman.id.au, benh@...nel.crashing.org,
paulus@...ba.org, linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arch:powerpc simple_write_to_buffer return check
On 05/02/21 12:51 pm, Christophe Leroy wrote:
> 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.
This was my first patch. I will try to provide better description of changes and subject in later patches.
> Le 04/02/2021 à 19:16, Mayank Suman a écrit :
>> Signed-off-by: Mayank Suman <mayanksuman@...e.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 ?
If -EINVAL is returned by simple_write_to_buffer, we should return -EINVAL.
> And why is it -EFAULT when ret is 0 ? EFAULT means error accessing memory.
>
The earlier check returned EFAULT when ret is 0. Most probably, there was an assumption
that writing 0 bytes (by simple_write_to_buffer) means a fault with memory (or error accessing memory).
Powered by blists - more mailing lists