public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan][PATCH iwl-net] idpf: only assign num refillqs if allocation was successful
@ 2026-03-07  2:12 Joshua Hay
  2026-03-19 16:38 ` [Intel-wired-lan] [PATCH " Salin, Samuel
  0 siblings, 1 reply; 2+ messages in thread
From: Joshua Hay @ 2026-03-07  2:12 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: netdev, Joshua Hay, Madhu Chittim, Aleksandr Loktionov

As reported by AI review [1], if the refillqs allocation fails, refillqs
will be NULL but num_refillqs will be non-zero. The release function
will then dereference refillqs since it thinks the refillqs are present,
resulting in a NULL ptr dereference.

Only assign the num refillqs if the allocation was successful. This will
prevent the release function from entering the loop and accessing
refillqs.

[1] https://lore.kernel.org/netdev/20260227035625.2632753-1-kuba@kernel.org/

Fixes: 95af467d9a4e3 ("idpf: configure resources for RX queues")
Signed-off-by: Joshua Hay <joshua.a.hay@intel.com>
Reviewed-by: Madhu Chittim <madhu.chittim@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index 252259993022..f6b3b15364ff 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -1860,13 +1860,13 @@ static int idpf_rxq_group_alloc(struct idpf_vport *vport,
 			idpf_queue_assign(HSPLIT_EN, q, hs);
 			idpf_queue_assign(RSC_EN, q, rsc);
 
-			bufq_set->num_refillqs = num_rxq;
 			bufq_set->refillqs = kcalloc(num_rxq, swq_size,
 						     GFP_KERNEL);
 			if (!bufq_set->refillqs) {
 				err = -ENOMEM;
 				goto err_alloc;
 			}
+			bufq_set->num_refillqs = num_rxq;
 			for (unsigned int k = 0; k < bufq_set->num_refillqs; k++) {
 				struct idpf_sw_queue *refillq =
 					&bufq_set->refillqs[k];
-- 
2.39.2


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

* RE: [Intel-wired-lan] [PATCH iwl-net] idpf: only assign num refillqs if allocation was successful
  2026-03-07  2:12 [Intel-wired-lan][PATCH iwl-net] idpf: only assign num refillqs if allocation was successful Joshua Hay
@ 2026-03-19 16:38 ` Salin, Samuel
  0 siblings, 0 replies; 2+ messages in thread
From: Salin, Samuel @ 2026-03-19 16:38 UTC (permalink / raw)
  To: Hay, Joshua A, intel-wired-lan@lists.osuosl.org
  Cc: netdev@vger.kernel.org, Hay, Joshua A, Chittim, Madhu,
	Loktionov, Aleksandr

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Joshua Hay
> Sent: Friday, March 6, 2026 6:13 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Hay, Joshua A <joshua.a.hay@intel.com>;
> Chittim, Madhu <madhu.chittim@intel.com>; Loktionov, Aleksandr
> <aleksandr.loktionov@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-net] idpf: only assign num refillqs if
> allocation was successful
> 
> As reported by AI review [1], if the refillqs allocation fails, refillqs will be NULL
> but num_refillqs will be non-zero. The release function will then dereference
> refillqs since it thinks the refillqs are present, resulting in a NULL ptr
> dereference.
> 
> Only assign the num refillqs if the allocation was successful. This will prevent
> the release function from entering the loop and accessing refillqs.
> 
> [1] https://lore.kernel.org/netdev/20260227035625.2632753-1-
> kuba@kernel.org/
> 
> Fixes: 95af467d9a4e3 ("idpf: configure resources for RX queues")
> Signed-off-by: Joshua Hay <joshua.a.hay@intel.com>
> Reviewed-by: Madhu Chittim <madhu.chittim@intel.com>
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---

Tested-by: Samuel Salin <Samuel.salin@intel.com>


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

end of thread, other threads:[~2026-03-19 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-07  2:12 [Intel-wired-lan][PATCH iwl-net] idpf: only assign num refillqs if allocation was successful Joshua Hay
2026-03-19 16:38 ` [Intel-wired-lan] [PATCH " Salin, Samuel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox