DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniil Iskhakov <dish@amicon.ru>
To: Akhil Goyal <gakhil@marvell.com>,
	Fan Zhang <fanzhang.oss@gmail.com>,
	Abhinandan Gujjar <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
Date: Thu, 16 Apr 2026 12:34:36 +0300	[thread overview]
Message-ID: <20260416093437.711435-1-dish@amicon.ru> (raw)

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


             reply	other threads:[~2026-04-16  9:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-16  9:34 Daniil Iskhakov [this message]
2026-04-16 14:44 ` [PATCH] cryptodev: reset resource pointers in init error path Gujjar, Abhinandan S
2026-06-02 19:27 ` [EXTERNAL] " Akhil Goyal

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=20260416093437.711435-1-dish@amicon.ru \
    --to=dish@amicon.ru \
    --cc=abhinandan.gujjar@intel.com \
    --cc=ade@amicon.ru \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=gakhil@marvell.com \
    --cc=konstantin.ananyev@huawei.com \
    --cc=rrv@amicon.ru \
    --cc=sdl.dpdk@linuxtesting.org \
    --cc=stable@dpdk.org \
    /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