power: reset: syscon-reboot: Use devm_register_sys_off_handler(RESTART)
PATCH 1/1 power: reset: syscon-reboot: Use devm_register_sys_off_handler(RESTART)
The driver registers its restart handler but never unregisters it:
there is no remove callback and the notifier block lives in the devm-allocated context. After unbind the freed notifier stays on the handler list and the next reboot oopses on it, observed on a Hi3798MV100 board (PC is at 0x0, LR is at notifier_call_chain).
Use the device-managed registration, which unregisters the handler on driver unbind; the DT-configured priority is passed through. This mirrors the conversion of the syscon-poweroff sibling.
--- drivers/power/reset/syscon-reboot.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/power/reset/syscon-reboot.c +7 -11
@@ -31,16 +31,12 @@ struct syscon_reboot_context {const struct reboot_data *rd;/* from of match data, if any */ struct reboot_mode_bits catchall;/* from DT */ - -struct notifier_block restart_handler; }; -static int syscon_restart_handle (struct notifier_block *this, -unsigned long mode,void *cmd) +static int syscon_restart_handle (struct sys_off_data *data) { -struct syscon_reboot_context *ctx = - container_of(this, struct syscon_reboot_context, - restart_handler); +struct syscon_reboot_context *ctx = data->cb_data; +unsigned int mode = data->mode;const struct reboot_mode_bits *mode_bits;if (ctx->rd) {
@@ -113,11 +109,11 @@ static int syscon_reboot_probe(struct platform_device *pdev) } } - ctx->restart_handler.notifier_call = syscon_restart_handle; - ctx->restart_handler.priority = priority; - err =register_restart_handler (&ctx->restart_handler); + err =devm_register_sys_off_handler (dev,SYS_OFF_MODE_RESTART , + priority, syscon_restart_handle, + ctx);if (err) -dev_err (dev,"can't register restart notifier (err=%d)\n" , err); +dev_err (dev,"can't register restart handler (err=%d)\n" , err);return err; }
Signature · 1 line
2.53.0
Sebastian Reichel
AppliedQuoted 11 lines · David Yang
The driver registers its restart handler but never unregisters it:
there is no remove callback and the notifier block lives in the devm-allocated context. After unbind the freed notifier stays on the handler list and the next reboot oopses on it, observed on a Hi3798MV100 board (PC is at0x0, LR is atnotifier_call_chain).Use the device-managed registration, which unregisters the handler on driver unbind; the DT-configured priority is passed through. This mirrors the conversion of the syscon-poweroff sibling.
[...]
Applied, thanks!
[1/1] power: reset: syscon-reboot: Use devm_register_sys_off_handler(RESTART)
commit: 808914f0c0141a5e0bd66e13daff7f9d2aa12155
Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>