Commit e2c1b823 authored by Pan Bian's avatar Pan Bian Committed by Herbert Xu

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: default avatarPan Bian <bianpan2016@163.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 37d84681
...@@ -566,8 +566,10 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, ...@@ -566,8 +566,10 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg,
* need to expand */ * need to expand */
tmp = kcalloc(tx_nents * 2, sizeof(*tmp), tmp = kcalloc(tx_nents * 2, sizeof(*tmp),
GFP_KERNEL); GFP_KERNEL);
if (!tmp) if (!tmp) {
err = -ENOMEM;
goto free; goto free;
}
sg_init_table(tmp, tx_nents * 2); sg_init_table(tmp, tx_nents * 2);
for (x = 0; x < tx_nents; x++) for (x = 0; x < tx_nents; x++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment