[PATCH] crypto: atmel-sha204a - Fix potential UAF and memory leak in remove path
Herbert Xu
herbert at gondor.apana.org.au
Fri Mar 13 21:17:43 PDT 2026
On Sat, Feb 21, 2026 at 08:04:25PM +0100, Thorsten Blum wrote:
>
> diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
> index 0fcf4a39de27..3afad915aae3 100644
> --- a/drivers/crypto/atmel-sha204a.c
> +++ b/drivers/crypto/atmel-sha204a.c
> @@ -190,10 +190,10 @@ 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;
> - }
> + if (atomic_read(&i2c_priv->tfm_count))
> + dev_warn(&client->dev, "Device is busy, will remove it anyhow\n");
> +
> + atmel_i2c_flush_queue();
How about only checking tfm_count after flushing the queue?
Removing a device that's in use isn't really something that should
trigger a kernel warning, unless it leads to an unrecovereable
problem.
Cheers,
--
Email: Herbert Xu <herbert at gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
More information about the linux-arm-kernel
mailing list