[v2] power: reset: msm: Process register_restart_handler() error
Commit Message
If registering restart handler fails for msm-restart result is not checked.
It may be irrelevant now (as stated in comment to register_restart_handler,
the function currently always returns zero), but if the behavior changes in
the future, an error at registration of handler will be silently skipped.
Add return error code and print error message too debug log in case of
non-zero result of register_restart_handler.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 18a702e0de98 ("power: reset: use restart_notifier mechanism for
msm-poweroff")
Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
---
v2: remove superfluous initialization, use specialized error handler for
probes,
set poweroff handler regardless of restart handler registration failure
as Sebastian Reichel <sebastian.reichel@collabora.com> suggested.
drivers/power/reset/msm-poweroff.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
b/drivers/power/reset/msm-poweroff.c
@@ -35,14 +35,17 @@ 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);
-
pm_power_off = do_msm_poweroff;
+ ret = register_restart_handler(&restart_nb);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "unable to register restart
handler\n");
+
return 0;
}
-- 2.34.1