Skip to content

Commit 5e023fe

Browse files
Dawei Fenggregkh
authored andcommitted
octeontx2-pf: fix SQB pointer leak on init failure
[ Upstream commit 62e7df6 ] otx2_init_hw_resources() initializes SQ aura and pool resources before several later setup steps. On failure, err_free_sq_ptrs only frees SQB pages, leaving the per-SQ sqb_ptrs arrays behind. Use otx2_free_sq_res() for the SQ unwind path and let it free sqb_ptrs even when sq->sqe has not been allocated yet. The bug was first flagged by an experimental analysis tool we are developing for kernel memory-management bugs while analyzing v6.13-rc1. The tool is still under development and is not yet publicly available. Manual inspection confirms that the bug is still present in v7.1.1. An x86_64 allyesconfig build showed no new warnings. As we do not have an OcteonTX2 PF device and the corresponding AF mailbox setup to test with, no runtime testing was able to be performed. Fixes: caa2da3 ("octeontx2-pf: Initialize and config queues") Cc: stable@vger.kernel.org Reviewed-by: Ratheesh Kannoth <rkannoth@marvell.com> Signed-off-by: Dawei Feng <dawei.feng@seu.edu.cn> Link: https://patch.msgid.link/20260630071625.349996-1-dawei.feng@seu.edu.cn Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a751ccd commit 5e023fe

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

  • drivers/net/ethernet/marvell/octeontx2/nic

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,13 +1438,13 @@ static void otx2_free_sq_res(struct otx2_nic *pf)
14381438
otx2_sq_free_sqbs(pf);
14391439
for (qidx = 0; qidx < otx2_get_total_tx_queues(pf); qidx++) {
14401440
sq = &qset->sq[qidx];
1441-
/* Skip freeing Qos queues if they are not initialized */
1442-
if (!sq->sqe)
1443-
continue;
1444-
qmem_free(pf->dev, sq->sqe);
1445-
qmem_free(pf->dev, sq->tso_hdrs);
1446-
qmem_free(pf->dev, sq->timestamps);
1447-
kfree(sq->sg);
1441+
/* sq->sqe is not initialized for unused QoS queues */
1442+
if (sq->sqe) {
1443+
qmem_free(pf->dev, sq->sqe);
1444+
qmem_free(pf->dev, sq->tso_hdrs);
1445+
qmem_free(pf->dev, sq->timestamps);
1446+
kfree(sq->sg);
1447+
}
14481448
kfree(sq->sqb_ptrs);
14491449
}
14501450
}
@@ -1570,13 +1570,12 @@ static int otx2_init_hw_resources(struct otx2_nic *pf)
15701570
return err;
15711571

15721572
err_free_nix_queues:
1573-
otx2_free_sq_res(pf);
15741573
otx2_free_cq_res(pf);
15751574
otx2_ctx_disable(mbox, NIX_AQ_CTYPE_RQ, false);
15761575
err_free_txsch:
15771576
otx2_txschq_stop(pf);
15781577
err_free_sq_ptrs:
1579-
otx2_sq_free_sqbs(pf);
1578+
otx2_free_sq_res(pf);
15801579
err_free_rq_ptrs:
15811580
otx2_free_aura_ptr(pf, AURA_NIX_RQ);
15821581
otx2_ctx_disable(mbox, NPA_AQ_CTYPE_POOL, true);

0 commit comments

Comments
 (0)