[PATCH] alpha: Improve error handling in alpha_rtc_init

From: Haoran Liu
Date: Mon Nov 27 2023 - 09:52:18 EST


This patch enhances the alpha_rtc_init function in
arch/alpha/kernel/rtc.c by adding error handling for the
platform_device_register_simple call.

Signed-off-by: Haoran Liu <liuhaoran14@xxxxxxx>
---
arch/alpha/kernel/rtc.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/alpha/kernel/rtc.c b/arch/alpha/kernel/rtc.c
index fb3025396ac9..576397b1fac2 100644
--- a/arch/alpha/kernel/rtc.c
+++ b/arch/alpha/kernel/rtc.c
@@ -209,6 +209,9 @@ alpha_rtc_init(void)
init_rtc_epoch();

pdev = platform_device_register_simple("rtc-alpha", -1, NULL, 0);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
+
rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
--
2.17.1