[PATCH AUTOSEL 6.18-6.12] crypto: atmel-sha204a - remove sysfs group before hwrng

From: Sasha Levin

Date: Mon Aug 31 2026 - 11:58:27 EST


From: Thorsten Blum <thorsten.blum@xxxxxxxxx>

[ Upstream commit d58b4a09d7f06750a706b70d068f5a678dad8233 ]

atmel_sha204a_probe() registers the hwrng before creating the sysfs
group. Mirror this order in atmel_sha204a_remove() by removing the sysfs
group before unregistering the hwrng.

Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---

LLM Generated explanations, may be completely bogus:

The background searches finished. The Herbert crypto tree is reachable,
and the upstream commit is **`d58b4a09d7f06`** (`crypto: atmel-sha204a -
remove sysfs group before hwrng`). It isn’t in the current **6.18.44**
ancestry — the buggy teardown order is still present in
`drivers/crypto/atmel-sha204a.c`.

That doesn’t change the earlier verdict: **YES** for backport to this
tree. It’s a one-line reorder that should keep the existing `kfree()`
(the LKML version also dropped it, which would be wrong here).

drivers/crypto/atmel-sha204a.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
index 8a3520c9a0ff5..2a37a4aeda92b 100644
--- a/drivers/crypto/atmel-sha204a.c
+++ b/drivers/crypto/atmel-sha204a.c
@@ -205,11 +205,10 @@ static void atmel_sha204a_remove(struct i2c_client *client)
{
struct atmel_i2c_client_priv *i2c_priv = i2c_get_clientdata(client);

+ sysfs_remove_group(&client->dev.kobj, &atmel_sha204a_groups);
devm_hwrng_unregister(&client->dev, &i2c_priv->hwrng);
atmel_i2c_flush_queue();

- sysfs_remove_group(&client->dev.kobj, &atmel_sha204a_groups);
-
kfree((void *)i2c_priv->hwrng.priv);
}

--
2.53.0