lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 10 May 2018 20:40:49 +0200
From:   Mathieu Malaterre <malat@...ian.org>
To:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Cc:     LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] nvmem: properly handle returned value nvmem_reg_read

On Thu, May 10, 2018 at 11:58 AM, Srinivas Kandagatla
<srinivas.kandagatla@...aro.org> wrote:
>
>
> On 09/05/18 19:57, Mathieu Malaterre wrote:
>>
>> Function nvmem_reg_read can return a non zero value indicating an error.
>> This returned value must be read and error propagated to
>> nvmem_cell_prepare_write_buffer. Silence the following gcc warning (W=1):
>>
>>    drivers/nvmem/core.c:1093:9: warning: variable ‘rc’ set but not used
>> [-Wunused-but-set-variable]
>>
>> Signed-off-by: Mathieu Malaterre <malat@...ian.org>
>> ---
>> v2: prefer ERR_PTR(-EINVAL) over a simple return NULL
>>
>>   drivers/nvmem/core.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
>> index b05aa8e81303..f7b6c85cf393 100644
>> --- a/drivers/nvmem/core.c
>> +++ b/drivers/nvmem/core.c
>> @@ -1107,6 +1107,8 @@ static void *nvmem_cell_prepare_write_buffer(struct
>> nvmem_cell *cell,
>>                 /* setup the first byte with lsb bits from nvmem */
>>                 rc = nvmem_reg_read(nvmem, cell->offset, &v, 1);
>> +               if (rc)
>> +                       goto err;
>>                 *b++ |= GENMASK(bit_offset - 1, 0) & v;
>>                 /* setup rest of the byte if any */
>> @@ -1125,11 +1127,16 @@ static void
>> *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
>>                 /* setup the last byte with msb bits from nvmem */
>>                 rc = nvmem_reg_read(nvmem,
>>                                     cell->offset + cell->bytes - 1, &v,
>> 1);
>> +               if (rc)
>> +                       goto err;
>>                 *p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) &
>> v;
>>         }
>>         return buf;
>> +err:
>> +       kfree(buf);
>> +       return ERR_PTR(-EINVAL);
>
> You should return ERR_PTR(rc) not EINVAL here.
> errors should always propagate to caller!

third time's a charm ?

Sorry about this, I was not paying attention.

> thanks,
> srini
>>
>>   }
>>     /**
>>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ