crypto: sha512-mb - add some missing unlock on error
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 25 Apr 2017 09:18:54 +0000 (12:18 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 18 May 2017 05:19:48 +0000 (13:19 +0800)
We recently added some new locking but missed the unlocks on these
error paths in sha512_ctx_mgr_submit().

Fixes: c459bd7beda0 ("crypto: sha512-mb - Protect sha512 mb ctx mgr access")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/sha512-mb/sha512_mb.c

index 2dd3674b5a1e468357fee68b4335ed17fa5e50c0..458409b7568d101da21c9a351ca8128108594e54 100644 (file)
@@ -269,19 +269,19 @@ static struct sha512_hash_ctx
                 * LAST
                 */
                ctx->error = HASH_CTX_ERROR_INVALID_FLAGS;
-               return ctx;
+               goto unlock;
        }
 
        if (ctx->status & HASH_CTX_STS_PROCESSING) {
                /* Cannot submit to a currently processing job. */
                ctx->error = HASH_CTX_ERROR_ALREADY_PROCESSING;
-               return ctx;
+               goto unlock;
        }
 
        if ((ctx->status & HASH_CTX_STS_COMPLETE) && !(flags & HASH_FIRST)) {
                /* Cannot update a finished job. */
                ctx->error = HASH_CTX_ERROR_ALREADY_COMPLETED;
-               return ctx;
+               goto unlock;
        }
 
 
@@ -363,6 +363,7 @@ static struct sha512_hash_ctx
        }
 
        ctx = sha512_ctx_mgr_resubmit(mgr, ctx);
+unlock:
        spin_unlock_irqrestore(&cstate->work_lock, irqflags);
        return ctx;
 }