mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
crypto: atmel-sha204a - Fix potential UAF and memory leak in remove path
Unregister the hwrng to prevent new ->read() calls and flush the Atmel
I2C workqueue before teardown to prevent a potential UAF if a queued
callback runs while the device is being removed.
Drop the early return to ensure sysfs entries are removed and
->hwrng.priv is freed, preventing a memory leak.
Fixes: da001fb651 ("crypto: atmel-i2c - add support for SHA204A random number generator")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
c8c4a2972f
commit
bab1adf3b8
|
|
@ -194,10 +194,8 @@ static void atmel_sha204a_remove(struct i2c_client *client)
|
|||
{
|
||||
struct atmel_i2c_client_priv *i2c_priv = i2c_get_clientdata(client);
|
||||
|
||||
if (atomic_read(&i2c_priv->tfm_count)) {
|
||||
dev_emerg(&client->dev, "Device is busy, will remove it anyhow\n");
|
||||
return;
|
||||
}
|
||||
devm_hwrng_unregister(&client->dev, &i2c_priv->hwrng);
|
||||
atmel_i2c_flush_queue();
|
||||
|
||||
sysfs_remove_group(&client->dev.kobj, &atmel_sha204a_groups);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user