* [PATCH] cryptodev: reset resource pointers in init error path
@ 2026-04-16 9:34 Daniil Iskhakov
2026-04-16 14:44 ` Gujjar, Abhinandan S
2026-06-02 19:27 ` [EXTERNAL] " Akhil Goyal
0 siblings, 2 replies; 3+ messages in thread
From: Daniil Iskhakov @ 2026-04-16 9:34 UTC (permalink / raw)
To: Akhil Goyal, Fan Zhang, Abhinandan Gujjar, Konstantin Ananyev
Cc: dev, stable, Daniil Iskhakov, Daniil Agalakov, sdl.dpdk, rrv
cryptodev_cb_init() may free partially allocated resources on failure,
but does not reset their pointers afterwards.
A later call to cryptodev_cb_cleanup() may then attempt to release both
resources even when one of them has already been freed, because the
cleanup logic does not rely on both pointers being valid independently.
Set freed pointers to NULL in the cryptodev_cb_init() error path to
make subsequent cleanup safe.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 1c3ffb95595e ("cryptodev: add enqueue and dequeue callbacks")
Cc: stable@dpdk.org
Signed-off-by: Daniil Agalakov <ade@amicon.ru>
Signed-off-by: Daniil Iskhakov <dish@amicon.ru>
---
Cc: abhinandan.gujjar@intel.com
Cc: sdl.dpdk@linuxtesting.org
Cc: rrv@amicon.ru
---
lib/cryptodev/rte_cryptodev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 50071935c2..5cb9c93c77 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -811,6 +811,7 @@ cryptodev_cb_init(struct rte_cryptodev *dev)
if (dev->deq_cbs == NULL) {
CDEV_LOG_ERR("Failed to allocate memory for deq callbacks");
rte_free(dev->enq_cbs);
+ dev->enq_cbs = NULL;
return -ENOMEM;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCH] cryptodev: reset resource pointers in init error path
2026-04-16 9:34 [PATCH] cryptodev: reset resource pointers in init error path Daniil Iskhakov
@ 2026-04-16 14:44 ` Gujjar, Abhinandan S
2026-06-02 19:27 ` [EXTERNAL] " Akhil Goyal
1 sibling, 0 replies; 3+ messages in thread
From: Gujjar, Abhinandan S @ 2026-04-16 14:44 UTC (permalink / raw)
To: Daniil Iskhakov, Akhil Goyal, Fan Zhang, Konstantin Ananyev
Cc: dev@dpdk.org, stable@dpdk.org, Daniil Agalakov,
sdl.dpdk@linuxtesting.org, rrv@amicon.ru
> -----Original Message-----
> From: Daniil Iskhakov <dish@amicon.ru>
> Sent: Thursday, April 16, 2026 3:05 PM
> To: Akhil Goyal <gakhil@marvell.com>; Fan Zhang
> <fanzhang.oss@gmail.com>; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; Konstantin Ananyev
> <konstantin.ananyev@huawei.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Daniil Iskhakov <dish@amicon.ru>;
> Daniil Agalakov <ade@amicon.ru>; sdl.dpdk@linuxtesting.org;
> rrv@amicon.ru
> Subject: [PATCH] cryptodev: reset resource pointers in init error path
>
> cryptodev_cb_init() may free partially allocated resources on failure, but does
> not reset their pointers afterwards.
>
> A later call to cryptodev_cb_cleanup() may then attempt to release both
> resources even when one of them has already been freed, because the
> cleanup logic does not rely on both pointers being valid independently.
>
> Set freed pointers to NULL in the cryptodev_cb_init() error path to make
> subsequent cleanup safe.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 1c3ffb95595e ("cryptodev: add enqueue and dequeue callbacks")
> Cc: stable@dpdk.org
>
> Signed-off-by: Daniil Agalakov <ade@amicon.ru>
> Signed-off-by: Daniil Iskhakov <dish@amicon.ru>
> ---
> Cc: abhinandan.gujjar@intel.com
> Cc: sdl.dpdk@linuxtesting.org
> Cc: rrv@amicon.ru
> ---
> lib/cryptodev/rte_cryptodev.c | 1 +
> 1 file changed, 1 insertion(+)
>
Acked-by: abhinandan.gujjar@intel.com
> diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
> index 50071935c2..5cb9c93c77 100644
> --- a/lib/cryptodev/rte_cryptodev.c
> +++ b/lib/cryptodev/rte_cryptodev.c
> @@ -811,6 +811,7 @@ cryptodev_cb_init(struct rte_cryptodev *dev)
> if (dev->deq_cbs == NULL) {
> CDEV_LOG_ERR("Failed to allocate memory for deq
> callbacks");
> rte_free(dev->enq_cbs);
> + dev->enq_cbs = NULL;
> return -ENOMEM;
> }
>
> --
> 2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [EXTERNAL] [PATCH] cryptodev: reset resource pointers in init error path
2026-04-16 9:34 [PATCH] cryptodev: reset resource pointers in init error path Daniil Iskhakov
2026-04-16 14:44 ` Gujjar, Abhinandan S
@ 2026-06-02 19:27 ` Akhil Goyal
1 sibling, 0 replies; 3+ messages in thread
From: Akhil Goyal @ 2026-06-02 19:27 UTC (permalink / raw)
To: Daniil Iskhakov, Fan Zhang, Abhinandan Gujjar, Konstantin Ananyev
Cc: dev@dpdk.org, stable@dpdk.org, Daniil Agalakov,
sdl.dpdk@linuxtesting.org, rrv@amicon.ru
> cryptodev_cb_init() may free partially allocated resources on failure,
> but does not reset their pointers afterwards.
>
> A later call to cryptodev_cb_cleanup() may then attempt to release both
> resources even when one of them has already been freed, because the
> cleanup logic does not rely on both pointers being valid independently.
>
> Set freed pointers to NULL in the cryptodev_cb_init() error path to
> make subsequent cleanup safe.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 1c3ffb95595e ("cryptodev: add enqueue and dequeue callbacks")
> Cc: stable@dpdk.org
>
> Signed-off-by: Daniil Agalakov <ade@amicon.ru>
> Signed-off-by: Daniil Iskhakov <dish@amicon.ru>
Applied to dpdk-next-crypto
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-02 19:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 9:34 [PATCH] cryptodev: reset resource pointers in init error path Daniil Iskhakov
2026-04-16 14:44 ` Gujjar, Abhinandan S
2026-06-02 19:27 ` [EXTERNAL] " Akhil Goyal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox