diff options
author | LABBE Corentin <clabbe.montjoie@gmail.com> | 2015-11-04 21:13:33 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-11-17 22:00:35 +0800 |
commit | c22dafb3b101073d83262b6c9020b6578d2a442a (patch) | |
tree | 28a6a7c4f0c6807f85a53c34f97714e45d743e21 /drivers/crypto/marvell/hash.c | |
parent | 652d5b8a8da8f05f7fb301067ffeef78b6f2eb01 (diff) |
crypto: marvell - 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/marvell/hash.c')
-rw-r--r-- | drivers/crypto/marvell/hash.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c index 6ec55b4a087b..683cca9ac3c4 100644 --- a/drivers/crypto/marvell/hash.c +++ b/drivers/crypto/marvell/hash.c @@ -712,6 +712,10 @@ static int mv_cesa_ahash_req_init(struct ahash_request *req, bool *cached) creq->req.base.type = CESA_STD_REQ; creq->src_nents = sg_nents_for_len(req->src, req->nbytes); + if (creq->src_nents < 0) { + dev_err(cesa_dev->dev, "Invalid number of src SG"); + return creq->src_nents; + } ret = mv_cesa_ahash_cache_req(req, cached); if (ret) |