]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.14/arm-mach-at91-pm-fix-possible-object-reference-leak.patch
Linux 4.19.41
[thirdparty/kernel/stable-queue.git] / releases / 5.0.14 / arm-mach-at91-pm-fix-possible-object-reference-leak.patch
1 From 8aa0fec4331ad11030cfc43ddd16b42dd759dfc2 Mon Sep 17 00:00:00 2001
2 From: Peng Hao <peng.hao2@zte.com.cn>
3 Date: Tue, 2 Apr 2019 22:12:38 +0800
4 Subject: arm/mach-at91/pm : fix possible object reference leak
5
6 [ Upstream commit ba5e60c9b75dec92d4c695b928f69300b17d7686 ]
7
8 of_find_device_by_node() takes a reference to the struct device
9 when it finds a match via get_device. When returning error we should
10 call put_device.
11
12 Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
13 Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
14 Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
15 Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
16 ---
17 arch/arm/mach-at91/pm.c | 6 ++++--
18 1 file changed, 4 insertions(+), 2 deletions(-)
19
20 diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
21 index 51e808adb00c..2a757dcaa1a5 100644
22 --- a/arch/arm/mach-at91/pm.c
23 +++ b/arch/arm/mach-at91/pm.c
24 @@ -591,13 +591,13 @@ static int __init at91_pm_backup_init(void)
25
26 np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam");
27 if (!np)
28 - goto securam_fail;
29 + goto securam_fail_no_ref_dev;
30
31 pdev = of_find_device_by_node(np);
32 of_node_put(np);
33 if (!pdev) {
34 pr_warn("%s: failed to find securam device!\n", __func__);
35 - goto securam_fail;
36 + goto securam_fail_no_ref_dev;
37 }
38
39 sram_pool = gen_pool_get(&pdev->dev, NULL);
40 @@ -620,6 +620,8 @@ static int __init at91_pm_backup_init(void)
41 return 0;
42
43 securam_fail:
44 + put_device(&pdev->dev);
45 +securam_fail_no_ref_dev:
46 iounmap(pm_data.sfrbu);
47 pm_data.sfrbu = NULL;
48 return ret;
49 --
50 2.20.1
51