[EXTERNAL] [PATCH] compressdev: fix device ID validation check
Akhil Goyal
gakhil at marvell.com
Wed Oct 8 10:20:18 CEST 2025
> From: Ashish Gupta <ashishg at marvell.com>
>
> nb_devs is incremented / decremented each time a compressdev is
> created/released. However, releasing device 1 incorrectly make device
> N invalid and inaccessible. Similarly when first half of the devices
> are released, rest half of the devices become inaccessible. This patch
> updates the validation check to ensure correct behavior.
Can you add fixes tag and cc stable at dpdk.org
>
> Signed-off-by: Ashish Gupta <ashishg at marvell.com>
> ---
> lib/compressdev/rte_compressdev.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/lib/compressdev/rte_compressdev.c
> b/lib/compressdev/rte_compressdev.c
> index 33de3f511b..8435bfa134 100644
> --- a/lib/compressdev/rte_compressdev.c
> +++ b/lib/compressdev/rte_compressdev.c
> @@ -104,12 +104,22 @@ rte_compressdev_pmd_get_named_dev(const char
> *name)
> return NULL;
> }
>
> +static inline uint8_t
> +rte_compressdev_is_valid_device_data(uint8_t dev_id)
> +{
> + if (dev_id >= RTE_COMPRESS_MAX_DEVS ||
> + compressdev_globals.devs[dev_id].data == NULL)
> + return 0;
> +
> + return 1;
> +}
> +
> static unsigned int
> rte_compressdev_is_valid_dev(uint8_t dev_id)
> {
> struct rte_compressdev *dev = NULL;
>
> - if (dev_id >= compressdev_globals.nb_devs)
> + if (!rte_compressdev_is_valid_device_data(dev_id))
> return 0;
>
> dev = rte_compressdev_get_dev(dev_id);
> --
> 2.43.0
More information about the dev
mailing list