Skip to content

Commit 0e2c8e6

Browse files
Lin Yujundlezcano
authored andcommitted
clocksource/drivers/timer-gxp: Add missing error handling in gxp_timer_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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent 6c3b62d commit 0e2c8e6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/clocksource/timer-gxp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ static int gxp_timer_probe(struct platform_device *pdev)
171171
{
172172
struct platform_device *gxp_watchdog_device;
173173
struct device *dev = &pdev->dev;
174+
int ret;
174175

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

190-
return platform_device_add(gxp_watchdog_device);
191+
ret = platform_device_add(gxp_watchdog_device);
192+
if (ret)
193+
platform_device_put(gxp_watchdog_device);
194+
195+
return ret;
191196
}
192197

193198
static const struct of_device_id gxp_timer_of_match[] = {

0 commit comments

Comments
 (0)