Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH 1/7] crypto: marvell: check return value of sg_nents_for_len
@ 2015-11-04 20:13 LABBE Corentin
  2015-11-04 20:13 ` [PATCH 2/7] crypto: talitos: " LABBE Corentin
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: LABBE Corentin @ 2015-11-04 20:13 UTC (permalink / raw)
  To: arno, boris.brezillon, clabbe.montjoie, davem, herbert,
	thomas.petazzoni
  Cc: linux-crypto, linux-kernel

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>
---
 drivers/crypto/marvell/cipher.c | 8 ++++++++
 drivers/crypto/marvell/hash.c   | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/crypto/marvell/cipher.c b/drivers/crypto/marvell/cipher.c
index 3df2f4e..78cf6f9 100644
--- a/drivers/crypto/marvell/cipher.c
+++ b/drivers/crypto/marvell/cipher.c
@@ -400,7 +400,15 @@ static int mv_cesa_ablkcipher_req_init(struct ablkcipher_request *req,
 		return -EINVAL;
 
 	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;
+	}
 	creq->dst_nents = sg_nents_for_len(req->dst, req->nbytes);
+	if (creq->dst_nents < 0) {
+		dev_err(cesa_dev->dev, "Invalid number of dst SG");
+		return creq->dst_nents;
+	}
 
 	mv_cesa_update_op_cfg(tmpl, CESA_SA_DESC_CFG_OP_CRYPT_ONLY,
 			      CESA_SA_DESC_CFG_OP_MSK);
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
index e8d0d71..250c6e5 100644
--- a/drivers/crypto/marvell/hash.c
+++ b/drivers/crypto/marvell/hash.c
@@ -710,6 +710,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)
-- 
2.4.10

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-11-17 14:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 20:13 [PATCH 1/7] crypto: marvell: check return value of sg_nents_for_len LABBE Corentin
2015-11-04 20:13 ` [PATCH 2/7] crypto: talitos: " LABBE Corentin
2015-11-04 20:13 ` [PATCH 3/7] crypto: sahara: " LABBE Corentin
2015-11-04 20:13 ` [PATCH 4/7] crypto: qce: " LABBE Corentin
2015-11-04 20:13 ` [PATCH 5/7] crypto: picoxcell: " LABBE Corentin
2015-11-06 15:30   ` Jamie Iles
2015-11-04 20:13 ` [PATCH 6/7] crypto: caam: " LABBE Corentin
2015-11-04 20:13 ` [PATCH 7/7] crypto: amcc: " LABBE Corentin
2015-11-17 14:09 ` [PATCH 1/7] crypto: marvell: " Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox