The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: liguangshuo@mail.sdu.edu.cn
Cc: shshaikh@marvell.com, manishc@marvell.com,
	gr-linux-nic-dev@marvell.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, himanshu.madhani@qlogic.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] qlcnic: Fix potential interrupt table leak on setup failure
Date: Sat, 05 Dec 2026 13:04:49 +0000	[thread overview]
Message-ID: <179647588931.3146.6443672227712860239@kernel.org> (raw)
In-Reply-To: <20261204130344.2418717-1-liguangshuo@mail.sdu.edu.cn>

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

      parent reply	other threads:[~2026-12-05 13:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179647588931.3146.6443672227712860239@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gr-linux-nic-dev@marvell.com \
    --cc=himanshu.madhani@qlogic.com \
    --cc=kuba@kernel.org \
    --cc=liguangshuo@mail.sdu.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manishc@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shshaikh@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox