]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.31/clk-samsung-exynos5-fix-possible-null-pointer-exception-on-platform_device_alloc-failure.patch
Linux 4.19.31
[thirdparty/kernel/stable-queue.git] / releases / 4.19.31 / clk-samsung-exynos5-fix-possible-null-pointer-exception-on-platform_device_alloc-failure.patch
CommitLineData
ec71c73b
GKH
1From 5f0b6216ea381b43c0dff88702d6cc5673d63922 Mon Sep 17 00:00:00 2001
2From: Krzysztof Kozlowski <krzk@kernel.org>
3Date: Thu, 21 Feb 2019 12:45:51 +0100
4Subject: clk: samsung: exynos5: Fix possible NULL pointer exception on platform_device_alloc() failure
5
6From: Krzysztof Kozlowski <krzk@kernel.org>
7
8commit 5f0b6216ea381b43c0dff88702d6cc5673d63922 upstream.
9
10During initialization of subdevices if platform_device_alloc() failed,
11returned NULL pointer will be later dereferenced. Add proper error
12paths to exynos5_clk_register_subcmu(). The return value of this
13function is still ignored because at this stage of init there is nothing
14we can do.
15
16Fixes: b06a532bf1fa ("clk: samsung: Add Exynos5 sub-CMU clock driver")
17Cc: <stable@vger.kernel.org>
18Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
19Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
20Signed-off-by: Stephen Boyd <sboyd@kernel.org>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23---
24 drivers/clk/samsung/clk-exynos5-subcmu.c | 10 ++++++++--
25 1 file changed, 8 insertions(+), 2 deletions(-)
26
27--- a/drivers/clk/samsung/clk-exynos5-subcmu.c
28+++ b/drivers/clk/samsung/clk-exynos5-subcmu.c
29@@ -136,15 +136,21 @@ static int __init exynos5_clk_register_s
30 {
31 struct of_phandle_args genpdspec = { .np = pd_node };
32 struct platform_device *pdev;
33+ int ret;
34
35 pdev = platform_device_alloc(info->pd_name, -1);
36+ if (!pdev)
37+ return -ENOMEM;
38+
39 pdev->dev.parent = parent;
40 pdev->driver_override = "exynos5-subcmu";
41 platform_set_drvdata(pdev, (void *)info);
42 of_genpd_add_device(&genpdspec, &pdev->dev);
43- platform_device_add(pdev);
44+ ret = platform_device_add(pdev);
45+ if (ret)
46+ platform_device_put(pdev);
47
48- return 0;
49+ return ret;
50 }
51
52 static int __init exynos5_clk_probe(struct platform_device *pdev)