diff mbox series

[-next,v3] rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register()

Message ID 20220915065253.43668-1-linyujun809@huawei.com
State Accepted
Headers show
Series [-next,v3] rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register() | expand

Commit Message

linyujun (C) Sept. 15, 2022, 6:52 a.m. UTC
Use platform_device_put() to free platform device before print
error message when platform_device_add() fails to run.

Fixes: 1a71fb84fda6 ("rtc: stmp3xxx: add wdt-accessor function")
Signed-off-by: Lin Yujun <linyujun809@huawei.com>
---
 drivers/rtc/rtc-stmp3xxx.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Wolfram Sang Sept. 15, 2022, 7:14 a.m. UTC | #1
On Thu, Sep 15, 2022 at 02:52:53PM +0800, Lin Yujun wrote:
> Use platform_device_put() to free platform device before print
> error message when platform_device_add() fails to run.
> 
> Fixes: 1a71fb84fda6 ("rtc: stmp3xxx: add wdt-accessor function")
> Signed-off-by: Lin Yujun <linyujun809@huawei.com>

Reviewed-by: Wolfram Sang <wsa@kernel.org>
Alexandre Belloni Oct. 12, 2022, 10:05 p.m. UTC | #2
On Thu, 15 Sep 2022 14:52:53 +0800, Lin Yujun wrote:
> Use platform_device_put() to free platform device before print
> error message when platform_device_add() fails to run.
> 
> 

Applied, thanks!

[1/1] rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register()
      commit: 0759011157b0d666b02b03b986d3de005d84027e

Best regards,
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index 40c0f7ed36e0..aae40d20d086 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -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)