diff mbox series

[v0,25/42] arch/um: Check notifier registration return value

Message ID 20211108101157.15189-26-bp@alien8.de
State Not Applicable
Headers show
Series None | expand

Commit Message

Borislav Petkov Nov. 8, 2021, 10:11 a.m. UTC
From: Borislav Petkov <bp@suse.de>

Avoid homegrown notifier registration checks.

No functional changes.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: linux-um@lists.infradead.org
---
 arch/um/drivers/mconsole_kern.c | 6 ++++--
 arch/um/kernel/um_arch.c        | 5 +++--
 2 files changed, 7 insertions(+), 4 deletions(-)

Comments

Johannes Berg Nov. 8, 2021, 10:23 a.m. UTC | #1
On Mon, 2021-11-08 at 11:11 +0100, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> Avoid homegrown notifier registration checks.
> 
> No functional changes.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: linux-um@lists.infradead.org
> ---
>  arch/um/drivers/mconsole_kern.c | 6 ++++--
>  arch/um/kernel/um_arch.c        | 5 +++--
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
> index 6ead1e240457..ceea940c0aa0 100644
> --- a/arch/um/drivers/mconsole_kern.c
> +++ b/arch/um/drivers/mconsole_kern.c
> @@ -856,8 +856,10 @@ static struct notifier_block panic_exit_notifier = {
>  
> 
>  static int add_notifier(void)
>  {
> -	atomic_notifier_chain_register(&panic_notifier_list,
> -			&panic_exit_notifier);
> +	if (atomic_notifier_chain_register(&panic_notifier_list,
> +					   &panic_exit_notifier))
> +		pr_warn("UM console panic notifier already registered\n");
> +
>  	return 0;

Maybe it should just return it? I don't see how this is ever possible,
since it's an initcall.

johannes
Borislav Petkov Nov. 8, 2021, 10:48 a.m. UTC | #2
On Mon, Nov 08, 2021 at 11:23:59AM +0100, Johannes Berg wrote:
> Maybe it should just return it? I don't see how this is ever possible,
> since it's an initcall.

If it would return it, you'd see the warning only when booting with
"initcall_debug", I believe.

I can do that if it is preferred...
Johannes Berg Nov. 8, 2021, 10:56 a.m. UTC | #3
On Mon, 2021-11-08 at 11:48 +0100, Borislav Petkov wrote:
> On Mon, Nov 08, 2021 at 11:23:59AM +0100, Johannes Berg wrote:
> > Maybe it should just return it? I don't see how this is ever possible,
> > since it's an initcall.
> 
> If it would return it, you'd see the warning only when booting with
> "initcall_debug", I believe.

Oh, I thought we'd fail :)

> I can do that if it is preferred...
> 
No strong opinion either way.

johannes
diff mbox series

Patch

diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 6ead1e240457..ceea940c0aa0 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -856,8 +856,10 @@  static struct notifier_block panic_exit_notifier = {
 
 static int add_notifier(void)
 {
-	atomic_notifier_chain_register(&panic_notifier_list,
-			&panic_exit_notifier);
+	if (atomic_notifier_chain_register(&panic_notifier_list,
+					   &panic_exit_notifier))
+		pr_warn("UM console panic notifier already registered\n");
+
 	return 0;
 }
 
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 54447690de11..6c0e562ff0b7 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -255,8 +255,9 @@  static struct notifier_block panic_exit_notifier = {
 
 void uml_finishsetup(void)
 {
-	atomic_notifier_chain_register(&panic_notifier_list,
-				       &panic_exit_notifier);
+	if (atomic_notifier_chain_register(&panic_notifier_list,
+					   &panic_exit_notifier))
+		pr_warn("UM panic notifier already registered\n");
 
 	uml_postsetup();