Skip to content

Commit d240b07

Browse files
tobluxherbertx
authored andcommitted
crypto: atmel-sha204a - Fix OOM ->tfm_count leak
If memory allocation fails, decrement ->tfm_count to avoid blocking future reads. Cc: stable@vger.kernel.org Fixes: da001fb ("crypto: atmel-i2c - add support for SHA204A random number generator") Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 889b0e2 commit d240b07

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/crypto/atmel-sha204a.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ static int atmel_sha204a_rng_read_nonblocking(struct hwrng *rng, void *data,
5252
rng->priv = 0;
5353
} else {
5454
work_data = kmalloc_obj(*work_data, GFP_ATOMIC);
55-
if (!work_data)
55+
if (!work_data) {
56+
atomic_dec(&i2c_priv->tfm_count);
5657
return -ENOMEM;
57-
58+
}
5859
work_data->ctx = i2c_priv;
5960
work_data->client = i2c_priv->client;
6061

0 commit comments

Comments
 (0)