* [PATCH] bnx2: remove deadcode in bnx2_init_cpus()
@ 2023-02-18 13:00 Maxim Korotkov
2023-02-18 16:13 ` Vadim Fedorenko
2023-02-19 9:48 ` Leon Romanovsky
0 siblings, 2 replies; 3+ messages in thread
From: Maxim Korotkov @ 2023-02-18 13:00 UTC (permalink / raw)
To: Rasesh Mody
Cc: Maxim Korotkov, GR-Linux-NIC-Dev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Michael Chan, netdev, linux-kernel,
lvc-project
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
Found by Security Code and Linux Verification
Center (linuxtesting.org) with SVACE
Fixes: 57579f7629a3 ("bnx2: Use request_firmware()")
Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com>
---
drivers/net/ethernet/broadcom/bnx2.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 9f473854b0f4..4dacb65a7348 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -3908,37 +3908,27 @@ bnx2_init_cpus(struct bnx2 *bp)
(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;
+ (void)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;
+ (void)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;
+ (void)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;
+ (void)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);
+ (void)load_cpu_fw(bp, &cpu_reg_cp, &mips_fw->cp);
-init_cpu_err:
- return rc;
+ return 0;
}
static void
--
2.37.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bnx2: remove deadcode in bnx2_init_cpus()
2023-02-18 13:00 [PATCH] bnx2: remove deadcode in bnx2_init_cpus() Maxim Korotkov
@ 2023-02-18 16:13 ` Vadim Fedorenko
2023-02-19 9:48 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2023-02-18 16:13 UTC (permalink / raw)
To: Maxim Korotkov, Rasesh Mody
Cc: GR-Linux-NIC-Dev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Michael Chan, netdev, linux-kernel, lvc-project
On 18.02.2023 13:00, Maxim Korotkov wrote:
> 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
>
In this case it's safe to convert both load_cpu_fw and bnx2_init_cpus to void
and remove the check in bnx2_init_chip. This will reduce the code a bit.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bnx2: remove deadcode in bnx2_init_cpus()
2023-02-18 13:00 [PATCH] bnx2: remove deadcode in bnx2_init_cpus() Maxim Korotkov
2023-02-18 16:13 ` Vadim Fedorenko
@ 2023-02-19 9:48 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2023-02-19 9:48 UTC (permalink / raw)
To: Maxim Korotkov
Cc: Rasesh Mody, GR-Linux-NIC-Dev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Michael Chan, netdev, linux-kernel,
lvc-project
On Sat, Feb 18, 2023 at 04:00:16PM +0300, Maxim Korotkov wrote:
> 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
>
> Found by Security Code and Linux Verification
> Center (linuxtesting.org) with SVACE
>
> Fixes: 57579f7629a3 ("bnx2: Use request_firmware()")
> Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com>
> ---
> drivers/net/ethernet/broadcom/bnx2.c | 22 ++++++----------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
> index 9f473854b0f4..4dacb65a7348 100644
> --- a/drivers/net/ethernet/broadcom/bnx2.c
> +++ b/drivers/net/ethernet/broadcom/bnx2.c
> @@ -3908,37 +3908,27 @@ bnx2_init_cpus(struct bnx2 *bp)
> (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;
> + (void)load_cpu_fw(bp, &cpu_reg_rxp, &mips_fw->rxp);
Please don't cast return types to void. It is useless.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-19 9:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-18 13:00 [PATCH] bnx2: remove deadcode in bnx2_init_cpus() Maxim Korotkov
2023-02-18 16:13 ` Vadim Fedorenko
2023-02-19 9:48 ` Leon Romanovsky
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).