]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/soc-bcm-brcmstb-don-t-leak-device-tree-node-referenc.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / soc-bcm-brcmstb-don-t-leak-device-tree-node-referenc.patch
1 From 72e3d211c63dc15d522aa350affb070899958a46 Mon Sep 17 00:00:00 2001
2 From: Yangtao Li <tiny.windzz@gmail.com>
3 Date: Sat, 24 Nov 2018 09:52:23 -0500
4 Subject: soc: bcm: brcmstb: Don't leak device tree node reference
5
6 [ Upstream commit 1861a7f07e02292830a1ca256328d370deefea30 ]
7
8 of_find_node_by_path() acquires a reference to the node returned by it
9 and that reference needs to be dropped by its caller. soc_is_brcmstb()
10 doesn't do that, so fix it.
11
12 [treding: slightly rewrite to avoid inline comparison]
13
14 Fixes: d52fad262041 ("soc: add stubs for brcmstb SoC's")
15 Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
16 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
17 Signed-off-by: Sasha Levin <sashal@kernel.org>
18 ---
19 drivers/soc/bcm/brcmstb/common.c | 6 +++++-
20 1 file changed, 5 insertions(+), 1 deletion(-)
21
22 diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
23 index 22e98a90468c..2f5ec424a390 100644
24 --- a/drivers/soc/bcm/brcmstb/common.c
25 +++ b/drivers/soc/bcm/brcmstb/common.c
26 @@ -31,13 +31,17 @@ static const struct of_device_id brcmstb_machine_match[] = {
27
28 bool soc_is_brcmstb(void)
29 {
30 + const struct of_device_id *match;
31 struct device_node *root;
32
33 root = of_find_node_by_path("/");
34 if (!root)
35 return false;
36
37 - return of_match_node(brcmstb_machine_match, root) != NULL;
38 + match = of_match_node(brcmstb_machine_match, root);
39 + of_node_put(root);
40 +
41 + return match != NULL;
42 }
43
44 static const struct of_device_id sun_top_ctrl_match[] = {
45 --
46 2.19.1
47