[PATCH 09/12] crypto: atmel-ecc - simplify remove path and relax busy handling
Lothar Rubusch
l.rubusch at gmail.com
Sun May 17 11:06:36 PDT 2026
Simplify atmel_ecc_remove() by removing early exit logic and
centralizing client retrieval and validation.
Previously the driver returned early when active transform users
were detected, which could leave partially initialized state
without proper cleanup.
Replace this with a warning when active transforms are present,
but continue with full teardown of crypto registration and
device cleanup.
This ensures consistent removal behaviour even when the device
is still in use.
Signed-off-by: Lothar Rubusch <l.rubusch at gmail.com>
---
drivers/crypto/atmel-ecc.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index dcfc09d24497..ce7a2e750ba8 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -346,21 +346,14 @@ static int atmel_ecc_probe(struct i2c_client *client)
static void atmel_ecc_remove(struct i2c_client *client)
{
- struct atmel_i2c_client_priv *i2c_priv = i2c_get_clientdata(client);
+ struct atmel_i2c_client_priv *i2c_priv;
- /* Return EBUSY if i2c client already allocated. */
- if (atomic_read(&i2c_priv->tfm_count)) {
- /*
- * After we return here, the memory backing the device is freed.
- * That happens no matter what the return value of this function
- * is because in the Linux device model there is no error
- * handling for unbinding a driver.
- * If there is still some action pending, it probably involves
- * accessing the freed memory.
- */
- dev_emerg(&client->dev, "Device is busy, expect memory corruption.\n");
+ i2c_priv = i2c_get_clientdata(client);
+ if (WARN_ON(!i2c_priv))
return;
- }
+
+ if (atomic_read(&i2c_priv->tfm_count))
+ dev_warn(&client->dev, "Device is busy, remove it anyhow\n");
crypto_unregister_kpp(&atmel_ecdh_nist_p256);
--
2.53.0
More information about the linux-arm-kernel
mailing list