diff mbox series

net: netxen: report error on version offset reading

Message ID 20230329162629.96590-1-den-plotnikov@yandex-team.ru (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: netxen: report error on version offset reading | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 89 this patch: 89
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 89 this patch: 89
netdev/checkpatch warning CHECK: Alignment should match open parenthesis WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ...
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Denis Plotnikov March 29, 2023, 4:26 p.m. UTC
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(-)

Comments

Leon Romanovsky March 29, 2023, 6:59 p.m. UTC | #1
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
>
Denis Plotnikov March 30, 2023, 6:01 a.m. UTC | #2
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
>>
diff mbox series

Patch

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)) {