summaryrefslogtreecommitdiffstats
path: root/crypto/algif_skcipher.c
diff options
context:
space:
mode:
authorPan Bian <bianpan2016@163.com>2016-11-30 21:04:43 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2016-12-01 08:06:43 -0500
commite2c1b82330bcd77ffeb6dc5a18a4c6ce8d3e1fd3 (patch)
treecaf2188d54cd65ebbe14d8d3ac8227aec0032b4a /crypto/algif_skcipher.c
parent37d8468108efb19b80aa8484534f8850ed60dbfb (diff)
crypto: algif_skcipher - set error code when kcalloc fails
Fix bug https://bugzilla.kernel.org/show_bug.cgi?id=188521. In function skcipher_recvmsg_async(), variable err takes the return value, and its value should be negative on failures. Because variable err may be reassigned and checked before calling kcalloc(), its value may be 0 (indicates no error) even if kcalloc() fails. This patch fixes the bug by explicitly assigning -ENOMEM to err when kcalloc() returns a NULL pointer. Signed-off-by: Pan Bian <bianpan2016@163.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/algif_skcipher.c')
-rw-r--r--crypto/algif_skcipher.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 28556fce4267..bfb0a1a2507a 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -566,8 +566,10 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg,
566 * need to expand */ 566 * need to expand */
567 tmp = kcalloc(tx_nents * 2, sizeof(*tmp), 567 tmp = kcalloc(tx_nents * 2, sizeof(*tmp),
568 GFP_KERNEL); 568 GFP_KERNEL);
569 if (!tmp) 569 if (!tmp) {
570 err = -ENOMEM;
570 goto free; 571 goto free;
572 }
571 573
572 sg_init_table(tmp, tx_nents * 2); 574 sg_init_table(tmp, tx_nents * 2);
573 for (x = 0; x < tx_nents; x++) 575 for (x = 0; x < tx_nents; x++)