]>
Commit | Line | Data |
---|---|---|
ec71c73b GKH |
1 | From 5f0b6216ea381b43c0dff88702d6cc5673d63922 Mon Sep 17 00:00:00 2001 |
2 | From: Krzysztof Kozlowski <krzk@kernel.org> | |
3 | Date: Thu, 21 Feb 2019 12:45:51 +0100 | |
4 | Subject: clk: samsung: exynos5: Fix possible NULL pointer exception on platform_device_alloc() failure | |
5 | ||
6 | From: Krzysztof Kozlowski <krzk@kernel.org> | |
7 | ||
8 | commit 5f0b6216ea381b43c0dff88702d6cc5673d63922 upstream. | |
9 | ||
10 | During initialization of subdevices if platform_device_alloc() failed, | |
11 | returned NULL pointer will be later dereferenced. Add proper error | |
12 | paths to exynos5_clk_register_subcmu(). The return value of this | |
13 | function is still ignored because at this stage of init there is nothing | |
14 | we can do. | |
15 | ||
16 | Fixes: b06a532bf1fa ("clk: samsung: Add Exynos5 sub-CMU clock driver") | |
17 | Cc: <stable@vger.kernel.org> | |
18 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | |
19 | Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> | |
20 | Signed-off-by: Stephen Boyd <sboyd@kernel.org> | |
21 | Signed-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) |