cryptodev: reset resource pointers in init error path
PATCH 1/1 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.
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- lib/cryptodev/rte_cryptodev.c | 1 + 1 file changed, 1 insertion(+)
lib/cryptodev/rte_cryptodev.c +1 -0
@@ -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 ; }
Signature · 1 line
2.43.0
Quoted 31 lines
-----Original Message-----
From: Daniil Iskhakov <[email protected]>
Sent: Thursday, April 16, 2026 3:05 PM
To: Akhil Goyal <[email protected]>; Fan Zhang <[email protected]>; Gujjar, Abhinandan S <[email protected]>; Konstantin Ananyev <[email protected]>
Cc: [email protected]; [email protected]; Daniil Iskhakov <[email protected]>; Daniil Agalakov <[email protected]>; [email protected]; [email protected]
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")Signed-off-by Daniil Agalakov <[email protected]>Signed-off-by Daniil Iskhakov <[email protected]>
Quoted 8 lines
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- lib/cryptodev/rte_cryptodev.c | 1 + 1 file changed, 1 insertion(+)
Quoted 15 lines
lib/cryptodev/rte_cryptodev.c +1
-1@@ -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
Akhil Goyal
AppliedQuoted 10 lines
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.
Quoted 7 lines
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 1c3ffb95595e ("cryptodev: add enqueue and dequeue callbacks")Signed-off-by Daniil Agalakov <[email protected]>Signed-off-by Daniil Iskhakov <[email protected]>
Applied to dpdk-next-crypto
Thanks.