Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[~shefty/rdma-dev.git] / drivers / crypto / tegra-aes.c
index e69f3bc473bede522aa7c31ead313402d8e3640c..eb32fd8cad147eacbaaf115516945736fa37ad7d 100644 (file)
@@ -672,8 +672,10 @@ static int tegra_aes_get_random(struct crypto_rng *tfm, u8 *rdata,
        mutex_lock(&aes_lock);
 
        ret = clk_prepare_enable(dd->aes_clk);
-       if (ret)
+       if (ret) {
+               mutex_unlock(&aes_lock);
                return ret;
+       }
 
        ctx->dd = dd;
        dd->ctx = ctx;
@@ -757,8 +759,10 @@ static int tegra_aes_rng_reset(struct crypto_rng *tfm, u8 *seed,
        dd->flags = FLAGS_ENCRYPT | FLAGS_RNG;
 
        ret = clk_prepare_enable(dd->aes_clk);
-       if (ret)
+       if (ret) {
+               mutex_unlock(&aes_lock);
                return ret;
+       }
 
        aes_set_key(dd);
 
@@ -1029,7 +1033,7 @@ out:
        if (dd->buf_out)
                dma_free_coherent(dev, AES_HW_DMA_BUFFER_SIZE_BYTES,
                        dd->buf_out, dd->dma_buf_out);
-       if (IS_ERR(dd->aes_clk))
+       if (!IS_ERR(dd->aes_clk))
                clk_put(dd->aes_clk);
        if (aes_wq)
                destroy_workqueue(aes_wq);