[PATCH] [power/reset] msm-poweroff: Add error handling

From: Haoran Liu
Date: Wed Nov 29 2023 - 08:18:29 EST


This patch introduces error handling for the
register_restart_handler call in the msm_restart_probe function
within drivers/power/reset/msm-poweroff.c. Previously, the
function lacked error checking after calling
register_restart_handler, which could potentially lead to
unnoticed failures during system restart operations.

Signed-off-by: Haoran Liu <liuhaoran14@xxxxxxx>
---
drivers/power/reset/msm-poweroff.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/power/reset/msm-poweroff.c b/drivers/power/reset/msm-poweroff.c
index d96d248a6e25..9fd84dfa6882 100644
--- a/drivers/power/reset/msm-poweroff.c
+++ b/drivers/power/reset/msm-poweroff.c
@@ -35,11 +35,18 @@ static void do_msm_poweroff(void)

static int msm_restart_probe(struct platform_device *pdev)
{
+ int ret;
+
msm_ps_hold = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(msm_ps_hold))
return PTR_ERR(msm_ps_hold);

- register_restart_handler(&restart_nb);
+ ret = register_restart_handler(&restart_nb);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "Failed to register restart handler: %d\n", ret);
+ return ret;
+ }

pm_power_off = do_msm_poweroff;

--
2.17.1