From: Dan Carpenter <dan.carpenter@oracle.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
Steffen Trumtrar <s.trumtrar@pengutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch 1/2] crypto: mxc-scc - signedness bugs in mxc_scc_ablkcipher_req_init()
Date: Fri, 22 Apr 2016 09:56:31 +0000 [thread overview]
Message-ID: <20160422095631.GC11398@mwanda> (raw)
->src_nents and ->dst_nents are unsigned so they can't be less than
zero. I fixed this by introducing a temporary "nents" variable.
Fixes: d293b640ebd5 ('crypto: mxc-scc - add basic driver for the MXC SCC')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/crypto/mxc-scc.c b/drivers/crypto/mxc-scc.c
index 38b01bf..9b348a7 100644
--- a/drivers/crypto/mxc-scc.c
+++ b/drivers/crypto/mxc-scc.c
@@ -210,18 +210,21 @@ static int mxc_scc_ablkcipher_req_init(struct ablkcipher_request *req,
struct mxc_scc_ctx *ctx)
{
struct mxc_scc *scc = ctx->scc;
+ int nents;
- ctx->src_nents = sg_nents_for_len(req->src, req->nbytes);
- if (ctx->src_nents < 0) {
+ nents = sg_nents_for_len(req->src, req->nbytes);
+ if (nents < 0) {
dev_err(scc->dev, "Invalid number of src SC");
- return ctx->src_nents;
+ return nents;
}
+ ctx->src_nents = nents;
- ctx->dst_nents = sg_nents_for_len(req->dst, req->nbytes);
- if (ctx->dst_nents < 0) {
+ nents = sg_nents_for_len(req->dst, req->nbytes);
+ if (nents < 0) {
dev_err(scc->dev, "Invalid number of dst SC");
- return ctx->dst_nents;
+ return nents;
}
+ ctx->dst_nents = nents;
ctx->size = 0;
ctx->offset = 0;
next reply other threads:[~2016-04-22 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-22 9:56 Dan Carpenter [this message]
2016-04-25 11:22 ` [patch 1/2] crypto: mxc-scc - signedness bugs in mxc_scc_ablkcipher_req_init() 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=20160422095631.GC11398@mwanda \
--to=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=s.trumtrar@pengutronix.de \
/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