Re: [PATCH] octeontx2-pf: Add error handling for cn10k_map_unmap_rq_policer().
From: Simon Horman
Date: Fri Apr 04 2025 - 07:06:33 EST
On Thu, Apr 03, 2025 at 11:13:03PM +0800, Wentao Liang wrote:
> The cn10k_free_matchall_ipolicer() calls the cn10k_map_unmap_rq_policer()
> for each queue in a for loop without checking for any errors. A proper
> implementation can be found in cn10k_set_matchall_ipolicer_rate().
>
> Check the return value of the cn10k_map_unmap_rq_policer() function during
> each loop. Jump to unlock function and return the error code if the
> funciton fails to unmap policer.
>
> Fixes: 2ca89a2c3752 ("octeontx2-pf: TC_MATCHALL ingress ratelimiting offload")
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
> index a15cc86635d6..ce58ad61198e 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c
> @@ -353,11 +353,13 @@ int cn10k_free_matchall_ipolicer(struct otx2_nic *pfvf)
>
> /* Remove RQ's policer mapping */
> for (qidx = 0; qidx < hw->rx_queues; qidx++)
> - cn10k_map_unmap_rq_policer(pfvf, qidx,
> - hw->matchall_ipolicer, false);
> + rc = cn10k_map_unmap_rq_policer(pfvf, qidx, hw->matchall_ipolicer, false);
> + if (rc)
> + goto out;
I'm not sure that bailing out is the right thing to do here.
Won't it result in leaked resources?
>
> rc = cn10k_free_leaf_profile(pfvf, hw->matchall_ipolicer);
>
> +out:
> mutex_unlock(&pfvf->mbox.lock);
> return rc;
> }
> --
> 2.42.0.windows.2
>
>