Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1533756 > unrolled thread
| Started by | Pan Bian <bianpan2016@163.com> |
|---|---|
| First post | 2016-12-01 03:30 +0100 |
| Last post | 2016-12-01 14:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] crypto: set error code when kcalloc fails Pan Bian <bianpan2016@163.com> - 2016-12-01 03:30 +0100
Re: [PATCH 1/1] crypto: set error code when kcalloc fails Herbert Xu <herbert@gondor.apana.org.au> - 2016-12-01 14:30 +0100
| From | Pan Bian <bianpan2016@163.com> |
|---|---|
| Date | 2016-12-01 03:30 +0100 |
| Subject | [PATCH 1/1] crypto: set error code when kcalloc fails |
| Message-ID | <sJpii-645-5@gated-at.bofh.it> |
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>
---
crypto/algif_skcipher.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 28556fc..bfb0a1a 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,
* need to expand */
tmp = kcalloc(tx_nents * 2, sizeof(*tmp),
GFP_KERNEL);
- if (!tmp)
+ if (!tmp) {
+ err = -ENOMEM;
goto free;
+ }
sg_init_table(tmp, tx_nents * 2);
for (x = 0; x < tx_nents; x++)
--
1.9.1
[toc] | [next] | [standalone]
| From | Herbert Xu <herbert@gondor.apana.org.au> |
|---|---|
| Date | 2016-12-01 14:30 +0100 |
| Message-ID | <sJzAZ-4ng-3@gated-at.bofh.it> |
| In reply to | #1533756 |
On Thu, Dec 01, 2016 at 10:04:43AM +0800, Pan Bian wrote: > 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> Patch applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web