s390/crypt: fix missing unlock in ctr_paes_crypt on error path
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 28 Feb 2017 06:05:59 +0000 (07:05 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 1 Mar 2017 08:59:27 +0000 (09:59 +0100)
The ctr mode of protected key aes uses the ctrblk page if the
ctrblk_lock could be acquired. If the protected key has to be
reestablished and this operation fails the unlock for the
ctrblk_lock is missing. Add it.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/crypto/paes_s390.c

index d69ea495c4d748748618b27d7414671529e1f41a..716b17238599f63107b27b6860c030b63dd757ba 100644 (file)
@@ -474,8 +474,11 @@ static int ctr_paes_crypt(struct blkcipher_desc *desc, unsigned long modifier,
                        ret = blkcipher_walk_done(desc, walk, nbytes - n);
                }
                if (k < n) {
-                       if (__ctr_paes_set_key(ctx) != 0)
+                       if (__ctr_paes_set_key(ctx) != 0) {
+                               if (locked)
+                                       spin_unlock(&ctrblk_lock);
                                return blkcipher_walk_done(desc, walk, -EIO);
+                       }
                }
        }
        if (locked)