From: <ashishg@marvell.com>
To: <dev@dpdk.org>
Cc: <fanzhang.oss@gmail.com>, Ashish Gupta <ashishg@marvell.com>
Subject: [PATCH] compressdev: fix device ID validation check
Date: Wed, 8 Oct 2025 07:45:23 +0000 [thread overview]
Message-ID: <20251008074532.3066685-1-ashishg@marvell.com> (raw)
From: Ashish Gupta <ashishg@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.
Signed-off-by: Ashish Gupta <ashishg@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
next reply other threads:[~2025-10-08 7:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-08 7:45 ashishg [this message]
2025-10-08 8:20 ` [EXTERNAL] " Akhil Goyal
2025-10-08 9:59 ` [PATCH v2] compressdev: update " ashishg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251008074532.3066685-1-ashishg@marvell.com \
--to=ashishg@marvell.com \
--cc=dev@dpdk.org \
--cc=fanzhang.oss@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).