All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] qlcnic: Fix potential interrupt table leak on setup failure
@ 2026-12-04 13:03 Guangshuo Li
  2026-12-04 13:07 ` netdev-bot+sinfo
  2026-12-05 13:04 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Guangshuo Li @ 2026-12-04 13:03 UTC (permalink / raw)
  To: shshaikh
  Cc: manishc, gr-linux-nic-dev, andrew+netdev, davem, edumazet, kuba,
	pabeni, himanshu.madhani, netdev, linux-kernel

The 82xx interrupt setup leaves intr_tbl allocated when firmware
configuration fails. A later open allocates another table and overwrites
the saved pointer.

Release the new table and clear its pointer on configuration failure.

This issue was found by our static analysis tool under development.

Fixes: 012ec81223aa ("qlcnic: Multi Tx queue support for 82xx Series adapter.")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index ff4f7cd20c79..ddd0c51dca10 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -897,10 +897,13 @@ int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *adapter, int op_type)
 		}
 
 		err = qlcnic_82xx_config_intrpt(adapter, 1);
-		if (err)
+		if (err) {
 			dev_err(&adapter->pdev->dev,
 				"Failed to configure Interrupt for %d vector\n",
 				ahw->num_msix);
+			vfree(ahw->intr_tbl);
+			ahw->intr_tbl = NULL;
+		}
 		return err;
 	}
 

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] qlcnic: Fix potential interrupt table leak on setup failure
  2026-12-04 13:03 [PATCH net] qlcnic: Fix potential interrupt table leak on setup failure Guangshuo Li
@ 2026-12-04 13:07 ` netdev-bot+sinfo
  2026-12-05 13:04 ` netdev-bot+sashiko
  1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-12-04 13:07 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: shshaikh, manishc, gr-linux-nic-dev, andrew+netdev, davem,
	edumazet, kuba, pabeni, himanshu.madhani, netdev, linux-kernel

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - What hardware the change was tested on. For driver fixes please
   mention the device (and if relevant firmware version) used for
   testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] qlcnic: Fix potential interrupt table leak on setup failure
  2026-12-04 13:03 [PATCH net] qlcnic: Fix potential interrupt table leak on setup failure Guangshuo Li
  2026-12-04 13:07 ` netdev-bot+sinfo
@ 2026-12-05 13:04 ` netdev-bot+sashiko
  1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 13:04 UTC (permalink / raw)
  To: liguangshuo
  Cc: shshaikh, manishc, gr-linux-nic-dev, andrew+netdev, davem,
	edumazet, kuba, pabeni, himanshu.madhani, netdev, linux-kernel

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix is incomplete.

--

qlcnic: Fix potential interrupt table leak on setup failure

The patch frees ahw->intr_tbl in qlcnic_82xx_mq_intrpt() when
qlcnic_82xx_config_intrpt() fails. Without this, a later open would
allocate a new table and overwrite the saved pointer.

> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
> index ff4f7cd20c791..ddd0c51dca106 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
> @@ -897,10 +897,13 @@ int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *adapter, int op_type)
>  		}
>  
>  		err = qlcnic_82xx_config_intrpt(adapter, 1);
> -		if (err)
> +		if (err) {
>  			dev_err(&adapter->pdev->dev,
>  				"Failed to configure Interrupt for %d vector\n",
>  				ahw->num_msix);
> +			vfree(ahw->intr_tbl);
> +			ahw->intr_tbl = NULL;
> +		}
>  		return err;
>  	}

[Severity: High]
Does this fix cover every place where "a later open allocates another table
and overwrites the saved pointer"?

qlcnic_82xx_mq_intrpt() assigns a fresh table every time it runs, and never
checks for or frees an existing one:

	ahw->intr_tbl =
		vzalloc(array_size(sizeof(struct qlcnic_intrpt_config),
				   ahw->num_msix));

It runs on every interface up:

__qlcnic_up()
  qlcnic_fw_create_ctx()
    qlcnic_82xx_mq_intrpt(dev, 1)

The matching teardown on the down path is qlcnic_fw_destroy_ctx() in
qlcnic_ctx.c. It sends the firmware DEL but does not free the table:

	if (qlcnic_82xx_check(adapter) &&
	    (adapter->flags & QLCNIC_MSIX_ENABLED) &&
	    qlcnic_check_multi_tx(adapter) &&
	    !adapter->ahw->diag_test)
			qlcnic_82xx_config_intrpt(adapter, 0);

The err_out path in qlcnic_fw_create_ctx() works the same way when
qlcnic_fw_cmd_create_rx_ctx() or qlcnic_fw_cmd_create_tx_ctx() fails after
qlcnic_82xx_mq_intrpt() has succeeded:

err_out:
	if (qlcnic_82xx_check(dev) && (dev->flags & QLCNIC_MSIX_ENABLED) &&
	    qlcnic_check_multi_tx(dev) && !dev->ahw->diag_test)
			qlcnic_82xx_config_intrpt(dev, 0);

qlcnic_teardown_intr() is the only place that vfree()s the 82xx table. It
runs on probe failure, remove, suspend and interrupt re-setup. It does not
run on ndo_stop, ndo_open or a context reset.

So on an 82xx adapter with MSI-X and multi-TX firmware, wouldn't each of
these still leak the previous intr_tbl?

  - ip link set dev X down / up, via qlcnic_close()->__qlcnic_down() and
    then qlcnic_open()->__qlcnic_up()
  - qlcnic_reset_context(), for example from the ethtool set_ringparam path
  - qlcnic_reset_hw_context(), via qlcnic_down()/qlcnic_up()
  - qlcnic_diag_free_res(), which clears diag_test and calls __qlcnic_up()
    again

Could the table be freed and set to NULL wherever the firmware DEL is sent,
meaning qlcnic_fw_destroy_ctx() and the qlcnic_fw_create_ctx() err_out
path? Another option is for qlcnic_82xx_mq_intrpt() to free or reuse any
existing table before it allocates a new one.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204130344.2418717-1-liguangshuo%40mail.sdu.edu.cn

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-05 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 13:03 [PATCH net] qlcnic: Fix potential interrupt table leak on setup failure Guangshuo Li
2026-12-04 13:07 ` netdev-bot+sinfo
2026-12-05 13:04 ` netdev-bot+sashiko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.