]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.111/crypto-crypto4xx-add-missing-of_node_put-after-of_de.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.111 / crypto-crypto4xx-add-missing-of_node_put-after-of_de.patch
CommitLineData
04fd09d4
SL
1From d4fd7535d0d5d181e52a5f61f063d4c07a080357 Mon Sep 17 00:00:00 2001
2From: Julia Lawall <Julia.Lawall@lip6.fr>
3Date: Sat, 23 Feb 2019 14:20:39 +0100
4Subject: crypto: crypto4xx - add missing of_node_put after
5 of_device_is_available
6
7[ Upstream commit 8c2b43d2d85b48a97d2f8279278a4aac5b45f925 ]
8
9Add an of_node_put when a tested device node is not available.
10
11The semantic patch that fixes this problem is as follows
12(http://coccinelle.lip6.fr):
13
14// <smpl>
15@@
16identifier f;
17local idexpression e;
18expression x;
19@@
20
21e = f(...);
22... when != of_node_put(e)
23 when != x = e
24 when != e = x
25 when any
26if (<+...of_device_is_available(e)...+>) {
27 ... when != of_node_put(e)
28(
29 return e;
30|
31+ of_node_put(e);
32 return ...;
33)
34}
35// </smpl>
36
37Fixes: 5343e674f32fb ("crypto4xx: integrate ppc4xx-rng into crypto4xx")
38Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
39Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
40Signed-off-by: Sasha Levin <sashal@kernel.org>
41---
42 drivers/crypto/amcc/crypto4xx_trng.c | 4 +++-
43 1 file changed, 3 insertions(+), 1 deletion(-)
44
45diff --git a/drivers/crypto/amcc/crypto4xx_trng.c b/drivers/crypto/amcc/crypto4xx_trng.c
46index 677ca17fd223..368c5599515e 100644
47--- a/drivers/crypto/amcc/crypto4xx_trng.c
48+++ b/drivers/crypto/amcc/crypto4xx_trng.c
49@@ -80,8 +80,10 @@ void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
50
51 /* Find the TRNG device node and map it */
52 trng = of_find_matching_node(NULL, ppc4xx_trng_match);
53- if (!trng || !of_device_is_available(trng))
54+ if (!trng || !of_device_is_available(trng)) {
55+ of_node_put(trng);
56 return;
57+ }
58
59 dev->trng_base = of_iomap(trng, 0);
60 of_node_put(trng);
61--
622.19.1
63