All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tony Nguyen" <anthony.l.nguyen@intel.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH net-next v3 07/14] idpf: refactor idpf to use libie_pci APIs
Date: Sat, 16 May 2026 22:45:31 +0000	[thread overview]
Message-ID: <20260516224532.45240C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260515224443.2772147-8-anthony.l.nguyen@intel.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Missing NULL check for `libie_pci_get_mmio_addr()` can lead to kernel panic.
- [High] Teardown sequence in `idpf_remove()` causes Use-After-Free and unmapped MMIO page faults.
- [Medium] Uninitialized `__free(kfree)` variable declaration violates cleanup subsystem guidelines.
--

commit e19227dc4c557d70d94d43565d6b6daafde0cccd
Author: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Subject: idpf: refactor idpf to use libie_pci APIs

This commit refactors the idpf driver to use libie_pci initialization
and MMIO mapping APIs. It transitions the driver from open-coding BAR
resource mapping to utilizing the shared libie_mmio_info structures.

> diff --git a/drivers/net/ethernet/intel/idpf/idpf_dev.c b/drivers/net/ethernet/intel/idpf/idpf_dev.c
> index 1a0c71c95ef12..e36b0017186fd 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_dev.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_dev.c
[ ... ]
> @@ -93,14 +94,17 @@ static int idpf_intr_reg_init(struct idpf_vport *vport,
>  		goto free_reg_vals;
>  	}
>  
> +	mmio = &adapter->ctlq_ctx.mmio_info;
> +
>  	for (i = 0; i < num_vecs; i++) {
>  		struct idpf_q_vector *q_vector = &rsrc->q_vectors[i];
>  		u16 vec_id = rsrc->q_vector_idxs[i] - IDPF_MBX_Q_VEC;
>  		struct idpf_intr_reg *intr = &q_vector->intr_reg;
> +		struct idpf_vec_regs *reg = &reg_vals[vec_id];
>  		u32 spacing;
>  
> -		intr->dyn_ctl = idpf_get_reg_addr(adapter,
> -						  reg_vals[vec_id].dyn_ctl_reg);
> +		intr->dyn_ctl = libie_pci_get_mmio_addr(mmio,
> +							reg->dyn_ctl_reg);

libie_pci_get_mmio_addr() can return a NULL pointer if the provided offset
is invalid. If the firmware provides an unexpected or invalid offset, could
these pointer fields be set to NULL and cause a panic when accessed in
the interrupt handler or datapath? Is it possible to validate the return
value here before assigning it?

[ ... ]
> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> index d4546d62cca9f..3e6411a07e4d0 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
[ ... ]
> @@ -1037,7 +1072,6 @@ static int idpf_send_get_lan_memory_regions(struct idpf_adapter *adapter)
> +static int idpf_cfg_lan_memory_regions(struct idpf_adapter *adapter)
>  {
>  	struct virtchnl2_get_lan_memory_regions *rcvd_regions __free(kfree);
>  	struct idpf_vc_xn_params xn_params = {

This isn't a bug, but the cleanup subsystem guidelines recommend defining and
initializing scope-based cleanup variables in a single statement. If a future
patch introduces an early return before rcvd_regions is assigned, could this
cause the cleanup function to free an uninitialized stack variable?

[ ... ]
> @@ -3647,7 +3649,6 @@ int idpf_vc_core_init(struct idpf_adapter *adapter)
>   */
>  void idpf_vc_core_deinit(struct idpf_adapter *adapter)
>  {
> -	struct idpf_hw *hw = &adapter->hw;
>  	bool remove_in_prog;
>  
>  	if (!test_bit(IDPF_VC_CORE_INIT, adapter->flags))
> @@ -3672,12 +3673,10 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter)
>  
>  	idpf_vport_params_buf_rel(adapter);
>  
> -	kfree(hw->lan_regs);
> -	hw->lan_regs = NULL;
> -
>  	kfree(adapter->vports);
>  	adapter->vports = NULL;
>  
> +	idpf_decfg_lan_memory_regions(adapter);
>  	clear_bit(IDPF_VC_CORE_INIT, adapter->flags);
>  }

idpf_vc_core_deinit() now calls idpf_decfg_lan_memory_regions(), which
unmaps the MMIO regions. When this is called during the teardown sequence
in idpf_remove(), the netdevs are still registered. 

Could the datapath still execute ndo_start_xmit and attempt to write to
the now-unmapped q->tail, triggering a page fault? Would it be safer to
unregister the netdevs before unmapping the MMIO regions?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260515224443.2772147-1-anthony.l.nguyen@intel.com?part=7

  reply	other threads:[~2026-05-16 22:45 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 22:44 [PATCH net-next v3 00/14][pull request] Introduce iXD driver Tony Nguyen
2026-05-15 22:44 ` [PATCH net-next v3 01/14] virtchnl: create 'include/linux/intel' and move necessary header files Tony Nguyen
2026-05-21  0:52   ` Jakub Kicinski
2026-05-21  9:28     ` Larysa Zaremba
2026-05-21 13:56       ` Jakub Kicinski
2026-05-22 11:08         ` Alexander Lobakin
2026-05-22 15:40           ` Jakub Kicinski
2026-05-26 14:45             ` Alexander Lobakin
2026-05-26 21:36               ` Jacob Keller
2026-05-15 22:44 ` [PATCH net-next v3 02/14] libie: add PCI device initialization helpers to libie Tony Nguyen
2026-05-16 22:45   ` sashiko-bot
2026-05-18  6:46   ` Larysa Zaremba
2026-05-18 21:54   ` Bjorn Helgaas
2026-05-19  8:20     ` Philipp Stanner
2026-05-19 10:03       ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 03/14] libeth: allow to create fill queues without NAPI Tony Nguyen
2026-05-21  1:49   ` Jakub Kicinski
2026-05-21 10:07     ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 04/14] libie: add control queue support Tony Nguyen
2026-05-18  7:02   ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 05/14] libie: add bookkeeping support for control queue messages Tony Nguyen
2026-05-18  7:24   ` Larysa Zaremba
2026-05-21  1:51   ` Jakub Kicinski
2026-05-21  8:25     ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 06/14] idpf: remove 'vport_params_reqd' field Tony Nguyen
2026-05-15 22:44 ` [PATCH net-next v3 07/14] idpf: refactor idpf to use libie_pci APIs Tony Nguyen
2026-05-16 22:45   ` sashiko-bot [this message]
2026-05-18  7:40   ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 08/14] idpf: refactor idpf to use libie control queues Tony Nguyen
2026-05-18  8:01   ` Larysa Zaremba
2026-05-18 10:14     ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 09/14] idpf: make mbx_task queueing and cancelling more consistent Tony Nguyen
2026-05-15 22:44 ` [PATCH net-next v3 10/14] idpf: print a debug message and bail in case of non-event ctlq message Tony Nguyen
2026-05-15 22:44 ` [PATCH net-next v3 11/14] ixd: add basic driver framework for Intel(R) Control Plane Function Tony Nguyen
2026-05-18  8:32   ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 12/14] ixd: add reset checks and initialize the mailbox Tony Nguyen
2026-05-18  9:12   ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 13/14] ixd: add the core initialization Tony Nguyen
2026-05-18 10:01   ` Larysa Zaremba
2026-05-18 10:10   ` Larysa Zaremba
2026-05-15 22:44 ` [PATCH net-next v3 14/14] ixd: add devlink support Tony Nguyen
2026-05-18 10:11   ` Larysa Zaremba
2026-05-18 10:23 ` [PATCH net-next v3 00/14][pull request] Introduce iXD driver Larysa Zaremba

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=20260516224532.45240C19425@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 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.