Skip to contentSkip to conversation

net: netxen: report error on version offset reading

PATCH In review Denis Plotnikov 2 participants 3 messages Mar 29, 2023 – Mar 30, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: netxen: report error on version offset reading

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.

---
 drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +7 -2
index 35ec9aab3dc7b..92962dbb73ad0 100644
@@ -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)) {
Signature · 1 line
2.25.1
#1 lore raw
Quoted 15 lines · Denis Plotnikov

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.

---
 drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +0 -0
index 35ec9aab3dc7b..92962dbb73ad0 100644

drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c netxen_p3_has_mn(struct netxen_adapter *adapter) · line 1196

Quoted 7 lines
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +2 -2
@@ -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

Quoted 11 lines
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +5 -0
+		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)) {
Signature · 1 line
2.25.1
#2 lore raw
Quoted 28 lines · Leon Romanovsky
Quoted 15 lines · Denis Plotnikov

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.

---
  drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +0 -0
index 35ec9aab3dc7b..92962dbb73ad0 100644

drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c netxen_p3_has_mn(struct netxen_adapter *adapter) · line 1196

Quoted 7 lines
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +2 -2
@@ -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().

Quoted 1 line

Thanks

Well, ok. Then patch isn't needed.

Thanks for reviewing!

Denis

Quoted 12 lines
Quoted 12 lines
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c +5 -0
+		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)) {
Signature · 1 line
2.25.1