Skip to content
/ linux Public

Commit 2bfc83c

Browse files
tobluxgregkh
authored andcommitted
crypto: atmel-sha204a - Fix OOM ->tfm_count leak
[ Upstream commit d240b07 ] 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> [ adapted kmalloc_obj() macro to kmalloc(sizeof()) ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0629a1a commit 2bfc83c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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(sizeof(*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)