Re: [PATCH v5 net 1/4] net: hns3: fix vector resource leak in hns3_nic_alloc_vector_data
From: Simon Horman
Date: Wed Nov 25 2026 - 05:38:14 EST
On Wed, Nov 18, 2026 at 09:03:27PM +0800, Jijie Shao wrote:
> When devm_kcalloc() fails for priv->tqp_vector after get_vector() has
> already acquired MSI-X vectors, the error path returns without calling
> put_vector() to release them, leaving the hclge/hclgevf bookkeeping
> (num_msi_used, num_msi_left, vector_status[]) inconsistent.
>
> Call put_vector() for every acquired vector before returning the error,
> and reset priv->vector_num to 0 so the count never describes vectors
> that were already handed back.
>
> Fixes: dd38c72604dc ("net: hns3: fix for coalesce configuration lost during reset")
> Signed-off-by: Jijie Shao <shaojijie@xxxxxxxxxx>
> ---
> Changes in v4:
> - Correct the reason for resetting priv->vector_num. Sashiko pointed
> out that hns3_nic_dealloc_vector_data() is not reachable after
> hns3_nic_alloc_vector_data() fails, so the reset is not protecting
> that path; it keeps the count from describing vectors that were
> already handed back.
> v3: https://lore.kernel.org/all/20261030095633.377289-2-shaojijie@xxxxxxxxxx/
> Changes in v3:
> - Simplify commit message: drop the accumulated-leak consequence
> paragraph and clarify that the vector_num reset avoids a NULL
> deref in hns3_nic_dealloc_vector_data().
> v2: https://lore.kernel.org/all/20261021121426.3096838-2-shaojijie@xxxxxxxxxx/
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>