diff mbox series

[for-4.14.y,3/3] crypto: crypto4xx - fix a potential double free in ppc4xx_trng_probe

Message ID 1564517913-17164-3-git-send-email-amit.pundir@linaro.org
State New
Headers show
Series None | expand

Commit Message

Amit Pundir July 30, 2019, 8:18 p.m. UTC
From: Wen Yang <wen.yang99@zte.com.cn>


commit 95566aa75cd6b3b404502c06f66956b5481194b3 upstream.

There is a possible double free issue in ppc4xx_trng_probe():

85:	dev->trng_base = of_iomap(trng, 0);
86:	of_node_put(trng);          ---> released here
87:	if (!dev->trng_base)
88:		goto err_out;
...
110:	ierr_out:
111:		of_node_put(trng);  ---> double released here
...

This issue was detected by using the Coccinelle software.
We fix it by removing the unnecessary of_node_put().

Fixes: 5343e674f32f ("crypto4xx: integrate ppc4xx-rng into crypto4xx")
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>

Cc: <stable@vger.kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Allison Randal <allison@lohutok.net>
Cc: Armijn Hemel <armijn@tjaldur.nl>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>

---
Cleanly apply on 4.9.y as well.

 drivers/crypto/amcc/crypto4xx_trng.c | 1 -
 1 file changed, 1 deletion(-)

-- 
2.7.4

Comments

Greg KH July 31, 2019, 9:44 a.m. UTC | #1
On Wed, Jul 31, 2019 at 01:48:33AM +0530, Amit Pundir wrote:
> From: Wen Yang <wen.yang99@zte.com.cn>

> 

> commit 95566aa75cd6b3b404502c06f66956b5481194b3 upstream.

> 

> There is a possible double free issue in ppc4xx_trng_probe():

> 

> 85:	dev->trng_base = of_iomap(trng, 0);

> 86:	of_node_put(trng);          ---> released here

> 87:	if (!dev->trng_base)

> 88:		goto err_out;

> ...

> 110:	ierr_out:

> 111:		of_node_put(trng);  ---> double released here

> ...

> 

> This issue was detected by using the Coccinelle software.

> We fix it by removing the unnecessary of_node_put().

> 

> Fixes: 5343e674f32f ("crypto4xx: integrate ppc4xx-rng into crypto4xx")

> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>

> Cc: <stable@vger.kernel.org>

> Cc: "David S. Miller" <davem@davemloft.net>

> Cc: Thomas Gleixner <tglx@linutronix.de>

> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

> Cc: Allison Randal <allison@lohutok.net>

> Cc: Armijn Hemel <armijn@tjaldur.nl>

> Cc: Julia Lawall <Julia.Lawall@lip6.fr>

> Cc: linux-crypto@vger.kernel.org

> Cc: linux-kernel@vger.kernel.org

> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>

> ---

> Cleanly apply on 4.9.y as well.


This is already in the 4.14.135 kernel release.  Are you sure we need it
there again?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/crypto/amcc/crypto4xx_trng.c b/drivers/crypto/amcc/crypto4xx_trng.c
index 368c5599515e..a194ee0ddbb6 100644
--- a/drivers/crypto/amcc/crypto4xx_trng.c
+++ b/drivers/crypto/amcc/crypto4xx_trng.c
@@ -111,7 +111,6 @@  void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
 	return;
 
 err_out:
-	of_node_put(trng);
 	iounmap(dev->trng_base);
 	kfree(rng);
 	dev->trng_base = NULL;