Re: [PATCH net] bnge: use int for bnge_fix_rings_count() return value

Bhargava Chenna Marreddy <[email protected]>
Newsgroups org.kernel.vger.netdev
Message-ID <CANXQDtYzo0FtTxjq+vvSDn8AxZ9g6SaGF67FKEdj0PoGMr1+2w@mail.gmail.com>
On Sat, Aug 1, 2026 at 3:39 PM Alok Tiwari <[email protected]> wrote:
>
> bnge_fix_rings_count() returns 0 on success or a negative errno on failure
> However, bnge_adjust_rings() stores its return value in a u16 variable,
> causing negative error codes such as -ENOMEM to be converted to a large
> positive value.
>
> Use an int for the return code variable so that error values are
> preserved and propagated correctly.
>
> Fixes: 627c67f038d2 ("bng_en: Add resource management support")
> Signed-off-by: Alok Tiwari <[email protected]>

Reviewed-by: Bhargava Marreddy <[email protected]>

> ---
>  drivers/net/ethernet/broadcom/bnge/bnge_resc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
> index 0e94f092813e..4711dd4945ff 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
> @@ -163,7 +163,8 @@ static int bnge_adjust_rings(struct bnge_dev *bd, u16 *rx,
>         u16 tx_chunks = bnge_num_tx_to_cp(bd, *tx);
>
>         if (tx_chunks != *tx) {
> -               u16 tx_saved = tx_chunks, rc;
> +               u16 tx_saved = tx_chunks;
> +               int rc;
>
>                 rc = bnge_fix_rings_count(rx, &tx_chunks, max_nq, sh);
>                 if (rc)
> --
> 2.52.0
>
smime.p7s (application/pkcs7-signature, 5.4 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.