Commit 07590111 authored by Lin Yujun's avatar Lin Yujun Committed by Alexandre Belloni
Browse files

rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register()



Use platform_device_put() to free platform device before print
error message when platform_device_add() fails to run.

Fixes: 1a71fb84 ("rtc: stmp3xxx: add wdt-accessor function")
Signed-off-by: default avatarLin Yujun <linyujun809@huawei.com>
Reviewed-by: default avatarWolfram Sang <wsa@kernel.org>
Link: https://lore.kernel.org/r/20220915065253.43668-1-linyujun809@huawei.com


Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 25bcfaad
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -107,6 +107,8 @@ static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
		wdt_pdev->dev.parent = &rtc_pdev->dev;
		wdt_pdev->dev.platform_data = &wdt_pdata;
		rc = platform_device_add(wdt_pdev);
		if (rc)
			platform_device_put(wdt_pdev);
	}

	if (rc)