Commit 4d1de1e6 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Greg Kroah-Hartman

clk: samsung: exynos5: Fix possible NULL pointer exception on platform_device_alloc() failure

commit 5f0b6216 upstream.

During initialization of subdevices if platform_device_alloc() failed,
returned NULL pointer will be later dereferenced.  Add proper error
paths to exynos5_clk_register_subcmu().  The return value of this
function is still ignored because at this stage of init there is nothing
we can do.

Fixes: b06a532b ("clk: samsung: Add Exynos5 sub-CMU clock driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9aba7a8f
...@@ -136,15 +136,21 @@ static int __init exynos5_clk_register_subcmu(struct device *parent, ...@@ -136,15 +136,21 @@ static int __init exynos5_clk_register_subcmu(struct device *parent,
{ {
struct of_phandle_args genpdspec = { .np = pd_node }; struct of_phandle_args genpdspec = { .np = pd_node };
struct platform_device *pdev; struct platform_device *pdev;
int ret;
pdev = platform_device_alloc(info->pd_name, -1); pdev = platform_device_alloc(info->pd_name, -1);
if (!pdev)
return -ENOMEM;
pdev->dev.parent = parent; pdev->dev.parent = parent;
pdev->driver_override = "exynos5-subcmu"; pdev->driver_override = "exynos5-subcmu";
platform_set_drvdata(pdev, (void *)info); platform_set_drvdata(pdev, (void *)info);
of_genpd_add_device(&genpdspec, &pdev->dev); of_genpd_add_device(&genpdspec, &pdev->dev);
platform_device_add(pdev); ret = platform_device_add(pdev);
if (ret)
platform_device_put(pdev);
return 0; return ret;
} }
static int __init exynos5_clk_probe(struct platform_device *pdev) static int __init exynos5_clk_probe(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment