otx2_qos_disable_sq() asks the AF to disable the QoS send queue, its aura and its pool, but ignores the result of otx2_qos_ctx_disable(). If the mailbox request fails, for example on a timeout or an AQ error, the driver cannot confirm that all three contexts have been disabled. It frees the SQBs, the pool stack, and the aura flow-control buffer anyway, which the hardware may continue to reference. If the disable fails, log an error and keep the memory: leaking it is safer than freeing memory the hardware may still access. If the queue is not set up again, otx2_free_hw_resources() frees it later with the other queues when the interface goes down, after the SQ and NPA contexts of the whole LF have been disabled. Fixes: ab6dddd2a669 ("octeontx2-pf: qos send queues management") Signed-off-by: Yuho Choi --- Compile-tested only (x86_64 with COMPILE_TEST, OCTEONTX2_PF=m, W=1). I don't have OcteonTX2/CN10K hardware, and the disable only fails when the mailbox request to the AF fails, so I could not trigger this path. drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c b/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c index 683efce519af..e9ca884cfb4d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c @@ -283,7 +283,7 @@ void otx2_qos_disable_sq(struct otx2_nic *pfvf, int qidx) struct otx2_hw *hw = &pfvf->hw; struct otx2_snd_queue *sq; struct otx2_cq_queue *cq; - int pool_id, sq_idx; + int pool_id, sq_idx, err; sq_idx = hw->non_qos_queues + qidx; @@ -311,8 +311,16 @@ void otx2_qos_disable_sq(struct otx2_nic *pfvf, int qidx) otx2_cleanup_tx_cqes(pfvf, cq); mutex_lock(&pfvf->mbox.lock); - otx2_qos_ctx_disable(pfvf, sq_idx, pool_id); + err = otx2_qos_ctx_disable(pfvf, sq_idx, pool_id); mutex_unlock(&pfvf->mbox.lock); + if (err) { + /* The SQ, aura and pool may still be enabled, so don't free + * the memory they point to. + */ + netdev_err(pfvf->netdev, + "Failed to disable QoS SQ %d (%d)\n", sq_idx, err); + return; + } otx2_qos_sq_free_sqbs(pfvf, sq_idx); otx2_qos_aura_pool_free(pfvf, pool_id); base-commit: 37fa509e43ba59d7c329025436e8ea64bdf089d7 -- 2.56.1