public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH -next] rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register()
@ 2022-09-14  3:21 Lin Yujun
  2022-09-14 23:02 ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Lin Yujun @ 2022-09-14  3:21 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, mcoquelin.stm32, alexandre.torgue,
	wsa, akpm, wim
  Cc: linux-rtc, linux-stm32, linux-arm-kernel, linux-kernel

Use platform_device_put() to free platform device before print
error message when platform_device_add() fails to run. Add dev_err()
to report error in case of alloc memory to wdt_pdev fail.

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

diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index 40c0f7ed36e0..b2f4b034cdb6 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -107,6 +107,11 @@ 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);
+	} else {
+		dev_err(&rtc_pdev->dev,
+			"failed to allocate stmp3xxx_rtc_wdt\n");
 	}
 
 	if (rc)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-15  1:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-14  3:21 [PATCH -next] rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register() Lin Yujun
2022-09-14 23:02 ` Wolfram Sang
2022-09-15  1:29   ` linyujun (C)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox