Skip to content

Commit b5e5797

Browse files
jahay1anguy11
authored andcommitted
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/[email protected]/ Fixes: 95af467 ("idpf: configure resources for RX queues") Signed-off-by: Joshua Hay <[email protected]> Reviewed-by: Madhu Chittim <[email protected]> Reviewed-by: Aleksandr Loktionov <[email protected]> Tested-by: Samuel Salin <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 1eb0db7 commit b5e5797

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/net/ethernet/intel/idpf/idpf_txrx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,13 +1860,13 @@ static int idpf_rxq_group_alloc(struct idpf_vport *vport,
18601860
idpf_queue_assign(HSPLIT_EN, q, hs);
18611861
idpf_queue_assign(RSC_EN, q, rsc);
18621862

1863-
bufq_set->num_refillqs = num_rxq;
18641863
bufq_set->refillqs = kcalloc(num_rxq, swq_size,
18651864
GFP_KERNEL);
18661865
if (!bufq_set->refillqs) {
18671866
err = -ENOMEM;
18681867
goto err_alloc;
18691868
}
1869+
bufq_set->num_refillqs = num_rxq;
18701870
for (unsigned int k = 0; k < bufq_set->num_refillqs; k++) {
18711871
struct idpf_sw_queue *refillq =
18721872
&bufq_set->refillqs[k];

0 commit comments

Comments
 (0)