summaryrefslogtreecommitdiff
path: root/drivers/crypto/amcc
diff options
context:
space:
mode:
authorLABBE Corentin <clabbe.montjoie@gmail.com>2015-11-04 23:13:39 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2015-11-17 17:00:38 +0300
commit7aff7d0abc83b0991e83af3c43f0d0df47e7c3bf (patch)
tree091d87783b34b2da6e7237a6ec9db92c077295aa /drivers/crypto/amcc
parentf9970c2865d300bd0bb4ba006a0283a8ffa51ada (diff)
downloadlinux-7aff7d0abc83b0991e83af3c43f0d0df47e7c3bf.tar.xz
crypto: amcc - check return value of sg_nents_for_len
The sg_nents_for_len() function could fail, this patch add a check for its return value. Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/amcc')
-rw-r--r--drivers/crypto/amcc/crypto4xx_core.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
index 58a630e55d5d..62134c8a2260 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -781,6 +781,10 @@ u32 crypto4xx_build_pd(struct crypto_async_request *req,
/* figure how many gd is needed */
num_gd = sg_nents_for_len(src, datalen);
+ if ((int)num_gd < 0) {
+ dev_err(dev->core_dev->device, "Invalid number of src SG.\n");
+ return -EINVAL;
+ }
if (num_gd == 1)
num_gd = 0;