crypto_akcipher_maxsize() returns minimum length for output buffer or error code if key hasn't been set. Check for error before allocating memory. Signed-off-by: Tudor Ambarus <tudor.ambarus@xxxxxxxxxxxxx> --- crypto/asymmetric_keys/public_key.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index d3a989e..2b2f8bf 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c @@ -123,6 +123,11 @@ int public_key_verify_signature(const struct public_key *pkey, ret = -ENOMEM; outlen = crypto_akcipher_maxsize(tfm); + if (outlen < 0) { + ret = outlen; + goto error_free_req; + } + output = kmalloc(outlen, GFP_KERNEL); if (!output) goto error_free_req; -- 2.7.4