Subject: Re: [PATCH net] be2net: check properly status in lancer_cmd_get_file_len()

From: Ivan Vecera <[email-masked]>
Date: Mon, 16 Nov 2015 10:21:25 +0100

On 11/16/2015 09:57 AM, Sathya Perla wrote:
> On Fri, Nov 13, 2015 at 3:22 PM, Ivan Vecera <[email-masked]> wrote:
>> The lancer_cmd_get_file_len() calls lancer_cmd_read_object() to get
>> the current size of registers for ethtool registers dump. The size
>> is stored in data_read but only when the returned status is 0 otherwise
>> it is uninitialized thus random.
>>
>> Signed-off-by: Ivan Vecera <[email-masked]>
>> ---
>>   drivers/net/ethernet/emulex/benet/be_ethtool.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
>> index f4cb8e4..26b6192 100644
>> --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
>> +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
>> @@ -248,6 +248,8 @@ static u32 lancer_cmd_get_file_len(struct be_adapter *adapter, u8 *file_name)
>>          status = lancer_cmd_read_object(adapter, &data_len_cmd, 0, 0,
>>                                          file_name, &data_read, &eof,
>>                                          &addn_status);
>> +       if (status)
>> +               return 0;
>>
>>          return data_read;
>
> Ivan, unless I'm missing something...I see that "data_read" is
> initialized to 0 in this routine. So, this routine will return 0 when
> lancer_cmd_read_object() returns a non-zero status.

Yeah, you are right...my bad eyes. I was confused that status is read 
but not checked... In this case 'status' var can be removed.

Ivan