lkml.org 
[lkml]   [2023]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH v2] power: reset: msm: Process register_restart_handler() error
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(-)

diff --git a/drivers/power/reset/msm-poweroff.c
b/drivers/power/reset/msm-poweroff.c
index d96d248a6e25..0d568805e70e 100644
--- a/drivers/power/reset/msm-poweroff.c
+++ 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

\
 
 \ /
  Last update: 2023-11-20 17:47    [W:1.145 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site