Re: [PATCH v0 35/42] sh: Check notifier registration return value

From: Geert Uytterhoeven
Date: Mon Nov 08 2021 - 08:34:08 EST


Hi Borislav,

On Mon, Nov 8, 2021 at 1:50 PM Borislav Petkov <bp@xxxxxxxxx> wrote:
> From: Borislav Petkov <bp@xxxxxxx>
>
> Avoid homegrown notifier registration checks.
>
> No functional changes.
>
> Signed-off-by: Borislav Petkov <bp@xxxxxxx>

Thanks for your patch!

> --- a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
> +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
> @@ -1277,11 +1277,14 @@ static struct notifier_block sh7724_post_sleep_notifier = {
>
> static int __init sh7724_sleep_setup(void)
> {
> - atomic_notifier_chain_register(&sh_mobile_pre_sleep_notifier_list,
> - &sh7724_pre_sleep_notifier);
> + if (atomic_notifier_chain_register(&sh_mobile_pre_sleep_notifier_list,
> + &sh7724_pre_sleep_notifier))
> + pr_warn("SH7724 pre-sleep notifier already registered\n");
> +
> + if (atomic_notifier_chain_register(&sh_mobile_post_sleep_notifier_list,
> + &sh7724_post_sleep_notifier))
> + pr_warn("SH7724 pre-sleep notifier already registered\n");

Do you think these can actually fail?

>
> - atomic_notifier_chain_register(&sh_mobile_post_sleep_notifier_list,
> - &sh7724_post_sleep_notifier);
> return 0;
> }
> arch_initcall(sh7724_sleep_setup);

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds