Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: da001fb651b0 ("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>

authored by

Thorsten Blum and committed by
Herbert Xu
bab1adf3 c8c4a297

+2 -4
+2 -4
drivers/crypto/atmel-sha204a.c
··· 194 194 { 195 195 struct atmel_i2c_client_priv *i2c_priv = i2c_get_clientdata(client); 196 196 197 - if (atomic_read(&i2c_priv->tfm_count)) { 198 - dev_emerg(&client->dev, "Device is busy, will remove it anyhow\n"); 199 - return; 200 - } 197 + devm_hwrng_unregister(&client->dev, &i2c_priv->hwrng); 198 + atmel_i2c_flush_queue(); 201 199 202 200 sysfs_remove_group(&client->dev.kobj, &atmel_sha204a_groups); 203 201