[PATCH v9-S2 05/13] net/dpaa2: support meter and policing

Stephen Hemminger stephen at networkplumber.org
Tue Oct 13 16:56:55 CEST 2026


On Mon, 12 Oct 2026 12:34:36 +0530
Prashant Gupta <prashant.gupta_3 at nxp.com> wrote:

> +
> +	/* Check for duplicate ID and insert under lock to prevent TOCTOU. */
> +	rte_spinlock_lock(&priv->meter_lock);
> +	curr = LIST_FIRST(&priv->profiles);
> +	while (curr != NULL) {
> +		if (curr->profile_id == profile_id) {
> +			rte_spinlock_unlock(&priv->meter_lock);
> +			rte_mtr_error_set(error, EEXIST,
> +				RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
> +				NULL, "Meter profile ID already exists!");
> +			ret = -EEXIST;
> +			goto err;
> +		}
> +		curr = LIST_NEXT(curr, next);
> +	}

You are just open coding LIST_FOREACH() and other places.
Better to use the macro.


More information about the dev mailing list