diff options
author | LABBE Corentin <clabbe.montjoie@gmail.com> | 2015-11-04 21:13:36 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-11-17 15:00:36 +0100 |
commit | 4fa9948ca5bf308fabd5c9b584bf710f5d393859 (patch) | |
tree | 94d2ee7a7b27ab82fe1ad1cd0db09f549846602f /drivers/crypto/qce/ablkcipher.c | |
parent | crypto: sahara - check return value of sg_nents_for_len (diff) | |
download | linux-4fa9948ca5bf308fabd5c9b584bf710f5d393859.tar.xz linux-4fa9948ca5bf308fabd5c9b584bf710f5d393859.zip |
crypto: qce - 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/qce/ablkcipher.c')
-rw-r--r-- | drivers/crypto/qce/ablkcipher.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/crypto/qce/ablkcipher.c b/drivers/crypto/qce/ablkcipher.c index 2c0d63d48747..dbcbbe242bd6 100644 --- a/drivers/crypto/qce/ablkcipher.c +++ b/drivers/crypto/qce/ablkcipher.c @@ -83,6 +83,14 @@ qce_ablkcipher_async_req_handle(struct crypto_async_request *async_req) rctx->dst_nents = sg_nents_for_len(req->dst, req->nbytes); else rctx->dst_nents = rctx->src_nents; + if (rctx->src_nents < 0) { + dev_err(qce->dev, "Invalid numbers of src SG.\n"); + return rctx->src_nents; + } + if (rctx->dst_nents < 0) { + dev_err(qce->dev, "Invalid numbers of dst SG.\n"); + return -rctx->dst_nents; + } rctx->dst_nents += 1; |