aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/algif_skcipher.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index f2a88a7a71d3..3e84f4a729f0 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -251,6 +251,7 @@ static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock,
251 struct af_alg_control con = {}; 251 struct af_alg_control con = {};
252 long copied = 0; 252 long copied = 0;
253 bool enc = 0; 253 bool enc = 0;
254 bool init = 0;
254 int err; 255 int err;
255 int i; 256 int i;
256 257
@@ -259,6 +260,7 @@ static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock,
259 if (err) 260 if (err)
260 return err; 261 return err;
261 262
263 init = 1;
262 switch (con.op) { 264 switch (con.op) {
263 case ALG_OP_ENCRYPT: 265 case ALG_OP_ENCRYPT:
264 enc = 1; 266 enc = 1;
@@ -280,7 +282,7 @@ static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock,
280 if (!ctx->more && ctx->used) 282 if (!ctx->more && ctx->used)
281 goto unlock; 283 goto unlock;
282 284
283 if (!ctx->used) { 285 if (init) {
284 ctx->enc = enc; 286 ctx->enc = enc;
285 if (con.iv) 287 if (con.iv)
286 memcpy(ctx->iv, con.iv->iv, ivsize); 288 memcpy(ctx->iv, con.iv->iv, ivsize);