Skip to content

Commit

Permalink
clocksource/drivers/timer-gxp: Add missing error handling in gxp_time…
Browse files Browse the repository at this point in the history
…r_probe

Add platform_device_put() to make sure to free the platform
device in the event platform_device_add() fails.

Fixes: 5184f4b ("clocksource/drivers/timer-gxp: Add HPE GXP Timer")
Signed-off-by: Lin Yujun <linyujun809@huawei.com>
Link: https://lore.kernel.org/r/20220914033018.97484-1-linyujun809@huawei.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
  • Loading branch information
Lin Yujun authored and Daniel Lezcano committed Sep 20, 2022
1 parent 6c3b62d commit 0e2c8e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/clocksource/timer-gxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ static int gxp_timer_probe(struct platform_device *pdev)
{
struct platform_device *gxp_watchdog_device;
struct device *dev = &pdev->dev;
int ret;

if (!gxp_timer) {
pr_err("Gxp Timer not initialized, cannot create watchdog");
Expand All @@ -187,7 +188,11 @@ static int gxp_timer_probe(struct platform_device *pdev)
gxp_watchdog_device->dev.platform_data = gxp_timer->counter;
gxp_watchdog_device->dev.parent = dev;

return platform_device_add(gxp_watchdog_device);
ret = platform_device_add(gxp_watchdog_device);
if (ret)
platform_device_put(gxp_watchdog_device);

return ret;
}

static const struct of_device_id gxp_timer_of_match[] = {
Expand Down

0 comments on commit 0e2c8e6

Please sign in to comment.