netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: netxen: report error on version offset reading
@ 2023-03-29 16:26 Denis Plotnikov
  2023-03-29 18:59 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Denis Plotnikov @ 2023-03-29 16:26 UTC (permalink / raw)
  To: GR-Linux-NIC-Dev
  Cc: manishc, rahulv, netdev, linux-kernel, davem, edumazet, kuba,
	pabeni

A static analyzer complains for non-checking the function returning value.
Although, the code looks like not expecting any problems with version
reading on netxen_p3_has_mn call, it seems the error still may happen.
So, at least, add error reporting to ease problems investigation.

Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
---
 drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
index 35ec9aab3dc7b..92962dbb73ad0 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
@@ -1192,8 +1192,13 @@ netxen_p3_has_mn(struct netxen_adapter *adapter)
 	if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
 		return 1;
 
-	netxen_rom_fast_read(adapter,
-			NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
+	if (netxen_rom_fast_read(adapter,
+			NX_FW_VERSION_OFFSET, (int *)&flashed_ver)) {
+		printk(KERN_ERR "%s: ERROR on flashed version reading",
+				netxen_nic_driver_name);
+		return 0;
+	}
+
 	flashed_ver = NETXEN_DECODE_VERSION(flashed_ver);
 
 	if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: netxen: report error on version offset reading
  2023-03-29 16:26 [PATCH] net: netxen: report error on version offset reading Denis Plotnikov
@ 2023-03-29 18:59 ` Leon Romanovsky
  2023-03-30  6:01   ` Denis Plotnikov
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2023-03-29 18:59 UTC (permalink / raw)
  To: Denis Plotnikov
  Cc: GR-Linux-NIC-Dev, manishc, rahulv, netdev, linux-kernel, davem,
	edumazet, kuba, pabeni

On Wed, Mar 29, 2023 at 07:26:29PM +0300, Denis Plotnikov wrote:
> A static analyzer complains for non-checking the function returning value.
> Although, the code looks like not expecting any problems with version
> reading on netxen_p3_has_mn call, it seems the error still may happen.
> So, at least, add error reporting to ease problems investigation.
> 
> Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
> ---
>  drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
> index 35ec9aab3dc7b..92962dbb73ad0 100644
> --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
> +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
> @@ -1192,8 +1192,13 @@ netxen_p3_has_mn(struct netxen_adapter *adapter)
>  	if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
>  		return 1;
>  
> -	netxen_rom_fast_read(adapter,
> -			NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
> +	if (netxen_rom_fast_read(adapter,
> +			NX_FW_VERSION_OFFSET, (int *)&flashed_ver)) {

1. Mo callers of netxen_rom_fast_read() print debug messages, so this
shouldn't too.
2. netxen_p3_has_mn() can't fail and by returning 0, you will cause to
unpredictable behaviour in netxen_validate_firmware().

Thanks

> +		printk(KERN_ERR "%s: ERROR on flashed version reading",
> +				netxen_nic_driver_name);
> +		return 0;
> +	}
> +
>  	flashed_ver = NETXEN_DECODE_VERSION(flashed_ver);
>  
>  	if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) {
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: netxen: report error on version offset reading
  2023-03-29 18:59 ` Leon Romanovsky
@ 2023-03-30  6:01   ` Denis Plotnikov
  0 siblings, 0 replies; 3+ messages in thread
From: Denis Plotnikov @ 2023-03-30  6:01 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: GR-Linux-NIC-Dev, manishc, rahulv, netdev, linux-kernel, davem,
	edumazet, kuba, pabeni


On 29.03.2023 21:59, Leon Romanovsky wrote:
> On Wed, Mar 29, 2023 at 07:26:29PM +0300, Denis Plotnikov wrote:
>> A static analyzer complains for non-checking the function returning value.
>> Although, the code looks like not expecting any problems with version
>> reading on netxen_p3_has_mn call, it seems the error still may happen.
>> So, at least, add error reporting to ease problems investigation.
>>
>> Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
>> ---
>>   drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
>> index 35ec9aab3dc7b..92962dbb73ad0 100644
>> --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
>> +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
>> @@ -1192,8 +1192,13 @@ netxen_p3_has_mn(struct netxen_adapter *adapter)
>>   	if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
>>   		return 1;
>>   
>> -	netxen_rom_fast_read(adapter,
>> -			NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
>> +	if (netxen_rom_fast_read(adapter,
>> +			NX_FW_VERSION_OFFSET, (int *)&flashed_ver)) {
> 1. Mo callers of netxen_rom_fast_read() print debug messages, so this
> shouldn't too.
> 2. netxen_p3_has_mn() can't fail and by returning 0, you will cause to
> unpredictable behaviour in netxen_validate_firmware().
>
> Thanks

Well, ok. Then patch isn't needed.

Thanks for reviewing!


Denis

>
>> +		printk(KERN_ERR "%s: ERROR on flashed version reading",
>> +				netxen_nic_driver_name);
>> +		return 0;
>> +	}
>> +
>>   	flashed_ver = NETXEN_DECODE_VERSION(flashed_ver);
>>   
>>   	if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) {
>> -- 
>> 2.25.1
>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-30  6:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29 16:26 [PATCH] net: netxen: report error on version offset reading Denis Plotnikov
2023-03-29 18:59 ` Leon Romanovsky
2023-03-30  6:01   ` Denis Plotnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).