RE: [EXT] [PATCH] bnx2x: Fix potential infinite loop

From: Sudarsana Reddy Kalluru
Date: Wed Apr 07 2021 - 21:44:36 EST



> -----Original Message-----
> From: Colin King <colin.king@xxxxxxxxxxxxx>
> Sent: Wednesday, April 7, 2021 7:58 PM
> To: Ariel Elior <aelior@xxxxxxxxxxx>; Sudarsana Reddy Kalluru
> <skalluru@xxxxxxxxxxx>; GR-everest-linux-l2 <GR-everest-linux-
> l2@xxxxxxxxxxx>; David S . Miller <davem@xxxxxxxxxxxxx>; Jakub Kicinski
> <kuba@xxxxxxxxxx>; Eilon Greenstein <eilong@xxxxxxxxxxxx>;
> netdev@xxxxxxxxxxxxxxx
> Cc: kernel-janitors@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: [EXT] [PATCH] bnx2x: Fix potential infinite loop
>
> External Email
>
> ----------------------------------------------------------------------
> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>
> The for_each_tx_queue loop iterates with a u8 loop counter i and compares
> this with the loop upper limit of bp->num_queues that is an int type. There
> is a potential infinite loop if bp->num_queues is larger than the u8 loop
> counter. Fix this by making the loop counter the same type as bp-
> >num_queues.
>
> Addresses-Coverity: ("Infinite loop")
> Fixes: ad5afc89365e ("bnx2x: Separate VF and PF logic")
> Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
> ---
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> index 1a6ec1a12d53..edfbeb710ad4 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> @@ -2959,7 +2959,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int
> load_mode)
>
> int bnx2x_drain_tx_queues(struct bnx2x *bp) {
> - u8 rc = 0, cos, i;
> + u8 rc = 0, cos;
> + int i;
>
> /* Wait until tx fastpath tasks complete */
> for_each_tx_queue(bp, i) {
> --
> 2.30.2

Thanks for the change. [just for the info, theoretical max num_queues value for bnx2x device is 33]

Acked-by: Sudarsana Reddy Kalluru <skalluru@xxxxxxxxxxx>