From: LABBE Corentin <clabbe.montjoie@gmail.com>
To: davem@davemloft.net, herbert@gondor.apana.org.au
Cc: LABBE Corentin <clabbe.montjoie@gmail.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/7] crypto: sahara: check return value of sg_nents_for_len
Date: Wed, 4 Nov 2015 21:13:35 +0100 [thread overview]
Message-ID: <1446668045-8620-3-git-send-email-clabbe.montjoie@gmail.com> (raw)
In-Reply-To: <1446668045-8620-1-git-send-email-clabbe.montjoie@gmail.com>
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/sahara.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c
index f68c24a..ea9f56a 100644
--- a/drivers/crypto/sahara.c
+++ b/drivers/crypto/sahara.c
@@ -477,7 +477,15 @@ static int sahara_hw_descriptor_create(struct sahara_dev *dev)
}
dev->nb_in_sg = sg_nents_for_len(dev->in_sg, dev->total);
+ if (dev->nb_in_sg < 0) {
+ dev_err(dev->device, "Invalid numbers of src SG.\n");
+ return dev->nb_in_sg;
+ }
dev->nb_out_sg = sg_nents_for_len(dev->out_sg, dev->total);
+ if (dev->nb_out_sg < 0) {
+ dev_err(dev->device, "Invalid numbers of dst SG.\n");
+ return dev->nb_out_sg;
+ }
if ((dev->nb_in_sg + dev->nb_out_sg) > SAHARA_MAX_HW_LINK) {
dev_err(dev->device, "not enough hw links (%d)\n",
dev->nb_in_sg + dev->nb_out_sg);
@@ -793,6 +801,10 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
dev->in_sg = rctx->in_sg;
dev->nb_in_sg = sg_nents_for_len(dev->in_sg, rctx->total);
+ if (dev->nb_in_sg < 0) {
+ dev_err(dev->device, "Invalid numbers of src SG.\n");
+ return dev->nb_in_sg;
+ }
if ((dev->nb_in_sg) > SAHARA_MAX_HW_LINK) {
dev_err(dev->device, "not enough hw links (%d)\n",
dev->nb_in_sg + dev->nb_out_sg);
--
2.4.10
next prev parent reply other threads:[~2015-11-04 20:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 20:13 [PATCH 1/7] crypto: marvell: " LABBE Corentin
2015-11-04 20:13 ` [PATCH 2/7] crypto: talitos: " LABBE Corentin
2015-11-04 20:13 ` LABBE Corentin [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446668045-8620-3-git-send-email-clabbe.montjoie@gmail.com \
--to=clabbe.montjoie@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®