From: T Pratham <t-pratham@ti.com>
To: T Pratham <t-pratham@ti.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: Sebin Francis <sebin.francis@ti.com>,
Manorit Chawdhry <m-chawdhry@ti.com>,
Praneeth Bajjuri <praneeth@ti.com>,
Vishal Mahaveer <vishalm@ti.com>, <linux-crypto@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH v12 02/15] crypto: ti - Fix spinlock inconsistency in DTHEv2
Date: Sat, 7 Nov 2026 21:36:17 +0530 [thread overview]
Message-ID: <20261107160631.2592763-3-t-pratham@ti.com> (raw)
In-Reply-To: <20261107160631.2592763-1-t-pratham@ti.com>
Probe and remove functions use spin_(un)lock for acquiring the
dthe_dev_list.lock. But dthe_get_dev uses the bh variant. Change
spin_(un)lock to spin_(un)lock_bh to avoid potential deadlock when a
softIRQ process tries to acquire the already held lock.
While we're here, also change the order in probe to add device to the
global list after all the fields in the dev_data are initialized. So
that a concurrent TFM allocation does not occur and try to fetch
uninitialized fields.
Fixes: 52f641bc63a46 ("crypto: ti - Add driver for DTHE V2 AES Engine (ECB, CBC)")
Signed-off-by: T Pratham <t-pratham@ti.com>
---
drivers/crypto/ti/dthev2-common.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/crypto/ti/dthev2-common.c b/drivers/crypto/ti/dthev2-common.c
index cb4b8b38a5ec8..a7d3831f2f9cb 100644
--- a/drivers/crypto/ti/dthev2-common.c
+++ b/drivers/crypto/ti/dthev2-common.c
@@ -152,15 +152,9 @@ static int dthe_probe(struct platform_device *pdev)
if (IS_ERR(dev_data->regs))
return PTR_ERR(dev_data->regs);
- platform_set_drvdata(pdev, dev_data);
-
- spin_lock(&dthe_dev_list.lock);
- list_add(&dev_data->list, &dthe_dev_list.dev_list);
- spin_unlock(&dthe_dev_list.lock);
-
ret = dthe_dma_init(dev_data);
if (ret)
- goto probe_dma_err;
+ return ret;
dev_data->engine = crypto_engine_alloc_init(dev, 1);
if (!dev_data->engine) {
@@ -174,24 +168,29 @@ static int dthe_probe(struct platform_device *pdev)
goto probe_engine_start_err;
}
+ spin_lock_bh(&dthe_dev_list.lock);
+ platform_set_drvdata(pdev, dev_data);
+ list_add(&dev_data->list, &dthe_dev_list.dev_list);
+ spin_unlock_bh(&dthe_dev_list.lock);
+
ret = dthe_register_algs();
if (ret) {
dev_err(dev, "Failed to register algs\n");
- goto probe_engine_start_err;
+ goto probe_register_algs_err;
}
return 0;
+probe_register_algs_err:
+ spin_lock_bh(&dthe_dev_list.lock);
+ list_del(&dev_data->list);
+ spin_unlock_bh(&dthe_dev_list.lock);
probe_engine_start_err:
crypto_engine_exit(dev_data->engine);
probe_engine_err:
dma_release_channel(dev_data->dma_aes_rx);
dma_release_channel(dev_data->dma_aes_tx);
dma_release_channel(dev_data->dma_sha_tx);
-probe_dma_err:
- spin_lock(&dthe_dev_list.lock);
- list_del(&dev_data->list);
- spin_unlock(&dthe_dev_list.lock);
return ret;
}
@@ -200,9 +199,9 @@ static void dthe_remove(struct platform_device *pdev)
{
struct dthe_data *dev_data = platform_get_drvdata(pdev);
- spin_lock(&dthe_dev_list.lock);
+ spin_lock_bh(&dthe_dev_list.lock);
list_del(&dev_data->list);
- spin_unlock(&dthe_dev_list.lock);
+ spin_unlock_bh(&dthe_dev_list.lock);
dthe_unregister_algs();
--
2.34.1
next prev parent reply other threads:[~2026-11-07 16:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 16:06 [PATCH v12 00/15] Fix several issues in DTHEv2 driver T Pratham
2026-11-07 16:06 ` [PATCH v12 01/15] crypto: ti - Use list_first_entry_or_null() in dthe_get_dev() T Pratham
2026-11-07 16:06 ` T Pratham [this message]
2026-11-07 16:06 ` [PATCH v12 03/15] crypto: ti - Fix potential memory corruption on highmem pages T Pratham
2026-11-07 16:06 ` [PATCH v12 04/15] crypto: ti - Fix use-after-free of dev_data on DTHEv2 driver removal T Pratham
2026-11-07 16:06 ` [PATCH v12 05/15] crypto: ti - Trim scatterlists to correct length in AES T Pratham
2026-11-07 16:06 ` [PATCH v12 06/15] crypto: ti - Align buffers to cacheline for DMA T Pratham
2026-11-07 16:06 ` [PATCH v12 07/15] crypto: ti - Separate padding buffer for src and dst T Pratham
2026-11-07 16:06 ` [PATCH v12 08/15] crypto: ti - Validate sg_nents_for_len() return value in DTHEv2 AES T Pratham
2026-11-07 16:06 ` [PATCH v12 09/15] crypto: ti - Validate sg_nents_for_len() return value in DTHEv2 AEAD T Pratham
2026-11-07 16:06 ` [PATCH v12 10/15] crypto: ti - Terminate DMA on all error paths in AES to clear descriptors T Pratham
2026-11-07 16:06 ` [PATCH v12 11/15] crypto: ti - Terminate DMA on all error paths in AEAD " T Pratham
2026-11-07 16:06 ` [PATCH v12 12/15] crypto: ti - Do AEAD software fallback on only ENOMEM T Pratham
2026-11-07 16:06 ` [PATCH v12 13/15] crypto: ti - Correct AEAD tag operations against dma cache invalidation T Pratham
2026-11-07 16:06 ` [PATCH v12 14/15] crypto: ti - Change lengths in AES to u64 to avoid potential overflows T Pratham
2026-11-07 16:06 ` [PATCH v12 15/15] crypto: ti - Change lengths in AEAD " T Pratham
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=20261107160631.2592763-3-t-pratham@ti.com \
--to=t-pratham@ti.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-chawdhry@ti.com \
--cc=praneeth@ti.com \
--cc=sebin.francis@ti.com \
--cc=vishalm@ti.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
all inboxes | Powered by JetHome®