From 3200da8d9afb3d0dc617515a2fe364d9d59ef523 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sun, 21 Oct 2012 19:56:42 +0800 Subject: crypto: tegra - fix missing unlock on error case Add the missing unlock on the error handling path in function tegra_aes_get_random() and tegra_aes_rng_reset(). Signed-off-by: Wei Yongjun Signed-off-by: Herbert Xu --- drivers/crypto/tegra-aes.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/crypto/tegra-aes.c') diff --git a/drivers/crypto/tegra-aes.c b/drivers/crypto/tegra-aes.c index 37185e6630cd..19adf1c7faa2 100644 --- a/drivers/crypto/tegra-aes.c +++ b/drivers/crypto/tegra-aes.c @@ -674,8 +674,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; @@ -759,8 +761,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); -- cgit v1.2.1 From d48e366e6efe46e0a6744980c18582fb0919a727 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 25 Oct 2012 22:55:04 +0800 Subject: crypto: tegra-aes - fix error-valued pointer dereference clk_put(dd->aes_clk) will dereference an error-valued pointer since the dd->aes_clk is a ERR_PTR() value. The correct check is call clk_put() if !IS_ERR(dd->aes_clk). dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun Signed-off-by: Herbert Xu --- drivers/crypto/tegra-aes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/crypto/tegra-aes.c') diff --git a/drivers/crypto/tegra-aes.c b/drivers/crypto/tegra-aes.c index 19adf1c7faa2..93059dc591aa 100644 --- a/drivers/crypto/tegra-aes.c +++ b/drivers/crypto/tegra-aes.c @@ -1035,7 +1035,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); -- cgit v1.2.1