summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/mxc-scc.c
diff options
context:
space:
mode:
authorDan Carpenter2016-04-22 11:56:31 +0200
committerHerbert Xu2016-04-25 13:14:52 +0200
commitb908bd3d4c4110a8a2ed84e2b6ab56fa7201db25 (patch)
tree9fc7a18513c926dc29011cdb7d8446c4d7c60cb3 /drivers/crypto/mxc-scc.c
parentcrypto: talitos - fix ahash algorithms registration (diff)
downloadkernel-qcow2-linux-b908bd3d4c4110a8a2ed84e2b6ab56fa7201db25.tar.gz
kernel-qcow2-linux-b908bd3d4c4110a8a2ed84e2b6ab56fa7201db25.tar.xz
kernel-qcow2-linux-b908bd3d4c4110a8a2ed84e2b6ab56fa7201db25.zip
crypto: mxc-scc - signedness bugs in mxc_scc_ablkcipher_req_init()
->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> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/mxc-scc.c')
-rw-r--r--drivers/crypto/mxc-scc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/crypto/mxc-scc.c b/drivers/crypto/mxc-scc.c
index 38b01bf141d3..9b348a78dd23 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;