diff mbox series

[3/3] mtd: phram: Fix error return code in phram_setup()

Message ID 20210408111514.1011020-4-yukuai3@huawei.com (mailing list archive)
State New, archived
Headers show
Series code optimization for mtd | expand

Commit Message

Yu Kuai April 8, 2021, 11:15 a.m. UTC
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/mtd/devices/phram.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Miquel Raynal April 8, 2021, 12:46 p.m. UTC | #1
Hi Yu,

Yu Kuai <yukuai3@huawei.com> wrote on Thu, 8 Apr 2021 19:15:14 +0800:

> Fix to return a negative error code from the error handling
> case instead of 0, as done elsewhere in this function.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>  drivers/mtd/devices/phram.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
> index 5b04ae6c3057..6ed6c51fac69 100644
> --- a/drivers/mtd/devices/phram.c
> +++ b/drivers/mtd/devices/phram.c
> @@ -270,6 +270,7 @@ static int phram_setup(const char *val)
>  	if (len == 0 || erasesize == 0 || erasesize > len
>  	    || erasesize > UINT_MAX || rem) {
>  		parse_err("illegal erasesize or len\n");
> +		ret = -EINVAL;
>  		goto error;
>  	}
>  

It looks like you're doing the opposite of what you say.

Thanks,
Miquèl
Yu Kuai April 8, 2021, 1:26 p.m. UTC | #2
On 2021/04/08 20:46, Miquel Raynal wrote:
> Hi Yu,
> 
> Yu Kuai <yukuai3@huawei.com> wrote on Thu, 8 Apr 2021 19:15:14 +0800:
> 
>> Fix to return a negative error code from the error handling
>> case instead of 0, as done elsewhere in this function.
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>>   drivers/mtd/devices/phram.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
>> index 5b04ae6c3057..6ed6c51fac69 100644
>> --- a/drivers/mtd/devices/phram.c
>> +++ b/drivers/mtd/devices/phram.c
>> @@ -270,6 +270,7 @@ static int phram_setup(const char *val)
>>   	if (len == 0 || erasesize == 0 || erasesize > len
>>   	    || erasesize > UINT_MAX || rem) {
>>   		parse_err("illegal erasesize or len\n");
>> +		ret = -EINVAL;
>>   		goto error;
>>   	}
>>   
> 
> It looks like you're doing the opposite of what you say.
> 
Hi,

sorry about that, I misunderstood 'fix to'.

Thanks
Yu Kuai
> Thanks,
> Miquèl
> .
>
diff mbox series

Patch

diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 5b04ae6c3057..6ed6c51fac69 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -270,6 +270,7 @@  static int phram_setup(const char *val)
 	if (len == 0 || erasesize == 0 || erasesize > len
 	    || erasesize > UINT_MAX || rem) {
 		parse_err("illegal erasesize or len\n");
+		ret = -EINVAL;
 		goto error;
 	}