]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.34/crypto-crypto4xx-add-missing-of_node_put-after-of_de.patch
Linux 4.19.34
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / crypto-crypto4xx-add-missing-of_node_put-after-of_de.patch
1 From 058592583359651b5fc125007dfa780c3fb6daf9 Mon Sep 17 00:00:00 2001
2 From: Julia Lawall <Julia.Lawall@lip6.fr>
3 Date: Sat, 23 Feb 2019 14:20:39 +0100
4 Subject: crypto: crypto4xx - add missing of_node_put after
5 of_device_is_available
6
7 [ Upstream commit 8c2b43d2d85b48a97d2f8279278a4aac5b45f925 ]
8
9 Add an of_node_put when a tested device node is not available.
10
11 The semantic patch that fixes this problem is as follows
12 (http://coccinelle.lip6.fr):
13
14 // <smpl>
15 @@
16 identifier f;
17 local idexpression e;
18 expression x;
19 @@
20
21 e = f(...);
22 ... when != of_node_put(e)
23 when != x = e
24 when != e = x
25 when any
26 if (<+...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
37 Fixes: 5343e674f32fb ("crypto4xx: integrate ppc4xx-rng into crypto4xx")
38 Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
39 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
40 Signed-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
45 diff --git a/drivers/crypto/amcc/crypto4xx_trng.c b/drivers/crypto/amcc/crypto4xx_trng.c
46 index 5e63742b0d22..53ab1f140a26 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 --
62 2.19.1
63