Skip to contentSkip to conversation

bnx2: remove deadcode in bnx2_init_cpus()

PATCH In review Maxim Korotkov 4 participants 4 messages Feb 19, 2023 – Feb 21, 2023

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

PATCH v2 1/1 bnx2: remove deadcode in bnx2_init_cpus()

The load_cpu_fw function has no error return code and always returns zero. Checking the value returned by this function does not make sense.
As a result, bnx2_init_cpus() will also return only zero Therefore, it will be safe to change the type of functions to void and remove checking

Found by Security Code and Linux Verification
Center (linuxtesting.org) with SVACE

Fixes 57579f7629a3 ("bnx2: Use request_firmware()")

---
changes v2:
- bnx2_init_cpu_fw() and bnx2_init_cpus() are void
- delete casts to void
- remove check of bnx2_init_cpus() in bnx2_init_chip()

 drivers/net/ethernet/broadcom/bnx2.c | 31 +++++++---------------------
 1 file changed, 8 insertions(+), 23 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +8 -23
index 9f473854b0f4..19b053c879b0 100644
@@ -3829,7 +3829,7 @@ load_rv2p_fw(struct bnx2 *bp, u32 rv2p_proc,
 	return 0;
 }
 
-static int
+static void
 load_cpu_fw(struct bnx2 *bp, const struct cpu_reg *cpu_reg,
 	    const struct bnx2_mips_fw_file_entry *fw_entry)
 {
@@ -3897,48 +3897,34 @@ load_cpu_fw(struct bnx2 *bp, const struct cpu_reg *cpu_reg,
 	val &= ~cpu_reg->mode_value_halt;
 	bnx2_reg_wr_ind(bp, cpu_reg->state, cpu_reg->state_value_clear);
 	bnx2_reg_wr_ind(bp, cpu_reg->mode, val);
-
-	return 0;
 }
 
-static int
+static void
 bnx2_init_cpus(struct bnx2 *bp)
 {
 	const struct bnx2_mips_fw_file *mips_fw =
 		(const struct bnx2_mips_fw_file *) bp->mips_firmware->data;
 	const struct bnx2_rv2p_fw_file *rv2p_fw =
 		(const struct bnx2_rv2p_fw_file *) bp->rv2p_firmware->data;
-	int rc;
 
 	/* Initialize the RV2P processor. */
 	load_rv2p_fw(bp, RV2P_PROC1, &rv2p_fw->proc1);
 	load_rv2p_fw(bp, RV2P_PROC2, &rv2p_fw->proc2);
 
 	/* Initialize the RX Processor. */
-	rc = load_cpu_fw(bp, &cpu_reg_rxp, &mips_fw->rxp);
-	if (rc)
-		goto init_cpu_err;
+	load_cpu_fw(bp, &cpu_reg_rxp, &mips_fw->rxp);
 
 	/* Initialize the TX Processor. */
-	rc = load_cpu_fw(bp, &cpu_reg_txp, &mips_fw->txp);
-	if (rc)
-		goto init_cpu_err;
+	load_cpu_fw(bp, &cpu_reg_txp, &mips_fw->txp);
 
 	/* Initialize the TX Patch-up Processor. */
-	rc = load_cpu_fw(bp, &cpu_reg_tpat, &mips_fw->tpat);
-	if (rc)
-		goto init_cpu_err;
+	load_cpu_fw(bp, &cpu_reg_tpat, &mips_fw->tpat);
 
 	/* Initialize the Completion Processor. */
-	rc = load_cpu_fw(bp, &cpu_reg_com, &mips_fw->com);
-	if (rc)
-		goto init_cpu_err;
+	load_cpu_fw(bp, &cpu_reg_com, &mips_fw->com);
 
 	/* Initialize the Command Processor. */
-	rc = load_cpu_fw(bp, &cpu_reg_cp, &mips_fw->cp);
-
-init_cpu_err:
-	return rc;
+	load_cpu_fw(bp, &cpu_reg_cp, &mips_fw->cp);
 }
 
 static void
@@ -4951,8 +4937,7 @@ bnx2_init_chip(struct bnx2 *bp)
 	} else
 		bnx2_init_context(bp);
 
-	if ((rc = bnx2_init_cpus(bp)) != 0)
-		return rc;
+	bnx2_init_cpus(bp);
 
 	bnx2_init_nvram(bp);
 
Signature · 1 line
2.37.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Maxim Korotkov

The load_cpu_fw function has no error return code and always returns zero. Checking the value returned by this function does not make sense.
As a result, bnx2_init_cpus() will also return only zero Therefore, it will be safe to change the type of functions to void and remove checking

Found by Security Code and Linux Verification
Center (linuxtesting.org) with SVACE

Quoted 8 lines
Fixes 57579f7629a3 ("bnx2: Use request_firmware()")

---
changes v2:
- bnx2_init_cpu_fw() and bnx2_init_cpus() are void
- delete casts to void
- remove check of bnx2_init_cpus() in bnx2_init_chip()

Thanks,

#2 lore raw
Quoted 20 lines · Leon Romanovsky
Quoted 10 lines · Maxim Korotkov

The load_cpu_fw function has no error return code and always returns zero. Checking the value returned by this function does not make sense.
As a result, bnx2_init_cpus() will also return only zero Therefore, it will be safe to change the type of functions to void and remove checking

Found by Security Code and Linux Verification
Center (linuxtesting.org) with SVACE

Quoted 8 lines
Fixes 57579f7629a3 ("bnx2: Use request_firmware()")

---
changes v2:
- bnx2_init_cpu_fw() and bnx2_init_cpus() are void
- delete casts to void
- remove check of bnx2_init_cpus() in bnx2_init_chip()

Quoted 2 lines

Thanks,

Not sure if it should go to -net, because it doesn't actually fix any bug, more like refactoring which goes to -next, I believe.

maintainer
#3 lore raw
In reply to Maxim Korotkov
Quoted 7 lines · Maxim Korotkov

The load_cpu_fw function has no error return code and always returns zero. Checking the value returned by this function does not make sense.
As a result, bnx2_init_cpus() will also return only zero Therefore, it will be safe to change the type of functions to void and remove checking

Quoted 5 lines

Found by Security Code and Linux Verification
Center (linuxtesting.org) with SVACE

Fixes 57579f7629a3 ("bnx2: Use request_firmware()")

I agree with Vadim, this looks like net-next material.

The net-next tree is currently closed. Please re-post when net-next re- opens, in ~2 weeks, with the Fixes tag stripped.

Thanks!

Paolo