notifiers: Return an error when callback is already registered
Subsystems (56)
Borislav Petkov
maintainerPATCH 26/42 alpha: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/alpha/kernel/setup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/alpha/kernel/setup.c +3 -2
@@ -465,8 +465,9 @@ setup_arch(char **cmdline_p) }/* Register a call for panic conditions. */ -atomic_notifier_chain_register (&panic_notifier_list, - &alpha_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, + &alpha_panic_block)) +pr_warn ("Panic notifier already registered\n" );#ifndef alpha_using_srm/* Assume that we've booted from SRM if we haven't booted from MILO.
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 42/42 notifier: Return an error when callback is already registered
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
The notifier registration routine doesn't return a proper error value when a callback has already been registered, leading people to track whether that registration has happened at the call site:
https://lore.kernel.org/amd-gfx/[email protected]/
Which is unnecessary.
Return -EEXIST to signal that case so that callers can act accordingly. Enforce callers to check the return value, leading to loud screaming during build:
arch/x86/kernel/cpu/mce/core.c: In function ‘mce_register_decode_chain’:
arch/x86/kernel/cpu/mce/core.c:167:2: error: ignoring return value of \
‘blocking_notifier_chain_register’, declared with attribute warn_unused_result [-Werror=unused-result]
blocking_notifier_chain_register(&x86_mce_decoder_chain, nb);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Drop the WARN too, while at it.
--- include/linux/notifier.h | 8 ++++---- kernel/notifier.c | 36 +++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 21 deletions(-)
include/linux/notifier.h +4 -4
@@ -141,13 +141,13 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);#ifdef __KERNEL__ -extern int atomic_notifier_chain_register (struct atomic_notifier_head *nh, +extern int __must_check atomic_notifier_chain_register (struct atomic_notifier_head *nh,struct notifier_block *nb); -extern int blocking_notifier_chain_register (struct blocking_notifier_head *nh, +extern int __must_check blocking_notifier_chain_register (struct blocking_notifier_head *nh,struct notifier_block *nb); -extern int raw_notifier_chain_register (struct raw_notifier_head *nh, +extern int __must_check raw_notifier_chain_register (struct raw_notifier_head *nh,struct notifier_block *nb); -extern int srcu_notifier_chain_register (struct srcu_notifier_head *nh, +extern int __must_check srcu_notifier_chain_register (struct srcu_notifier_head *nh,struct notifier_block *nb); extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
kernel/notifier.c +19 -17
@@ -20,13 +20,11 @@ BLOCKING_NOTIFIER_HEAD(reboot_notifier_list);*/ static int notifier_chain_register (struct notifier_block **nl, -struct notifier_block *n) +struct notifier_block *n) {while ((*nl) !=NULL ) { -if (unlikely ((*nl) == n)) { -WARN (1 ,"double register detected" ); -return 0 ; - } +if (unlikely ((*nl) == n)) +return -EEXIST ;if (n->priority > (*nl)->priority)break ; nl = &((*nl)->next);
@@ -134,10 +132,11 @@ static int notifier_call_chain_robust(struct notifier_block **nl,* * Adds a notifier to an atomic notifier chain. * -* Currently always returns zero. +* Returns 0 on success, %-EEXIST on error. */ -int atomic_notifier_chain_register (struct atomic_notifier_head *nh, -struct notifier_block *n) +int __must_check +atomic_notifier_chain_register (struct atomic_notifier_head *nh, +struct notifier_block *n) {unsigned long flags;int ret;
@@ -216,10 +215,11 @@ NOKPROBE_SYMBOL(atomic_notifier_call_chain);* Adds a notifier to a blocking notifier chain. * Must be called in process context. * -* Currently always returns zero. +* Returns 0 on success, %-EEXIST on error. */ -int blocking_notifier_chain_register (struct blocking_notifier_head *nh, -struct notifier_block *n) +int __must_check +blocking_notifier_chain_register (struct blocking_notifier_head *nh, +struct notifier_block *n) {int ret;
@@ -335,10 +335,11 @@ EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);* Adds a notifier to a raw notifier chain. * All locking must be provided by the caller. * -* Currently always returns zero. +* Returns 0 on success, %-EEXIST on error. */ -int raw_notifier_chain_register (struct raw_notifier_head *nh, -struct notifier_block *n) +int __must_check +raw_notifier_chain_register (struct raw_notifier_head *nh, +struct notifier_block *n) {return notifier_chain_register (&nh->head, n); }
@@ -406,10 +407,11 @@ EXPORT_SYMBOL_GPL(raw_notifier_call_chain);* Adds a notifier to an SRCU notifier chain. * Must be called in process context. * -* Currently always returns zero. +* Returns 0 on success, %-EEXIST on error. */ -int srcu_notifier_chain_register (struct srcu_notifier_head *nh, -struct notifier_block *n) +int __must_check +srcu_notifier_chain_register (struct srcu_notifier_head *nh, +struct notifier_block *n) {int ret;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 2/42 xen/x86: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/x86/xen/enlighten.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/xen/enlighten.c +3 -1
@@ -354,7 +354,9 @@ static struct notifier_block xen_panic_block = {int xen_panic_handler_init (void ) { -atomic_notifier_chain_register (&panic_notifier_list, &xen_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, &xen_panic_block)) +pr_warn ("Xen panic notifier already registered\n" ); +return 0 ; }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 4/42 clk: renesas: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/clk/renesas/clk-div6.c | 4 +++- drivers/clk/renesas/rcar-cpg-lib.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/clk/renesas/clk-div6.c +3 -1
@@ -306,7 +306,9 @@ struct clk * __init cpg_div6_register(const char *name,if (notifiers) { clock->nb.notifier_call = cpg_div6_clock_notifier_call; -raw_notifier_chain_register (notifiers, &clock->nb); + +if (raw_notifier_chain_register (notifiers, &clock->nb)) +pr_warn ("CPG DIV6 clock notifier already registered\n" ); }return clk;
drivers/clk/renesas/rcar-cpg-lib.c +3 -1
@@ -59,7 +59,9 @@ void cpg_simple_notifier_register(struct raw_notifier_head *notifiers, struct cpg_simple_notifier *csn) { csn->nb.notifier_call = cpg_simple_notifier_call; -raw_notifier_chain_register (notifiers, &csn->nb); + +if (raw_notifier_chain_register (notifiers, &csn->nb)) +pr_warn ("CPG notifier already registered\n" ); }/*
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 8/42 Drivers: hv: vmbus: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/hv/vmbus_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hv/vmbus_drv.c +2 -2
@@ -1574,8 +1574,8 @@ static int vmbus_bus_init(void)* the VMbus channel connection to prevent any VMbus * activity after the VM panics. */ -atomic_notifier_chain_register (&panic_notifier_list, - &hyperv_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, &hyperv_panic_block)) +pr_warn ("VMBus panic notifier already registered\n" );vmbus_request_offers ();
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 9/42 iio: proximity: cros_ec: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/iio/proximity/cros_ec_mkbp_proximity.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/proximity/cros_ec_mkbp_proximity.c +2 -1
@@ -234,7 +234,8 @@ static int cros_ec_mkbp_proximity_probe(struct platform_device *pdev)return ret; data->notifier.notifier_call = cros_ec_mkbp_proximity_notify; -blocking_notifier_chain_register (&ec->event_notifier, &data->notifier); +if (blocking_notifier_chain_register (&ec->event_notifier, &data->notifier)) +pr_warn ("cros-ec proximity notifier already registered\n" );return 0 ; }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 10/42 leds: trigger: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/leds/trigger/ledtrig-activity.c | 6 ++++-- drivers/leds/trigger/ledtrig-heartbeat.c | 6 ++++-- drivers/leds/trigger/ledtrig-panic.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-)
drivers/leds/trigger/ledtrig-activity.c +4 -2
@@ -247,8 +247,10 @@ static int __init activity_init(void)int rc =led_trigger_register (&activity_led_trigger);if (!rc) { -atomic_notifier_chain_register (&panic_notifier_list, - &activity_panic_nb); +if (atomic_notifier_chain_register (&panic_notifier_list, + &activity_panic_nb)) +pr_warn ("Activity LED trigger notifier already registered\n" ); +register_reboot_notifier (&activity_reboot_nb); }return rc;
drivers/leds/trigger/ledtrig-heartbeat.c +4 -2
@@ -190,8 +190,10 @@ static int __init heartbeat_trig_init(void)int rc =led_trigger_register (&heartbeat_led_trigger);if (!rc) { -atomic_notifier_chain_register (&panic_notifier_list, - &heartbeat_panic_nb); +if (atomic_notifier_chain_register (&panic_notifier_list, + &heartbeat_panic_nb)) +pr_warn ("Heartbeat LED Trigger notifier already registered\n" ); +register_reboot_notifier (&heartbeat_reboot_nb); }return rc;
drivers/leds/trigger/ledtrig-panic.c +2 -2
@@ -64,8 +64,8 @@ static long led_panic_blink(int state)static int __init ledtrig_panic_init (void ) { -atomic_notifier_chain_register (&panic_notifier_list, - &led_trigger_panic_nb); +if (atomic_notifier_chain_register (&panic_notifier_list, &led_trigger_panic_nb)) +pr_warn ("LED trigger panic notifier already registered\n" );led_trigger_register_simple ("panic" , &trigger); panic_blink = led_panic_blink;
Signature · 1 line
2.29.2
Borislav Petkov
maintainercover notifiers: Return an error when callback is already registered
From: Borislav Petkov <[email protected]>
Hi all,
this is a huge patchset for something which is really trivial - it changes the notifier registration routines to return an error value if a notifier callback is already present on the respective list of callbacks. For more details scroll to the last patch.
Everything before it is converting the callers to check the return value of the registration routines and issue a warning, instead of the WARN() notifier_chain_register() does now.
Before the last patch has been applied, though, that checking is a NOP which would make the application of those patches trivial - every maintainer can pick a patch at her/his discretion - only the last one enables the build warnings and that one will be queued only after the preceding patches have all been merged so that there are no build warnings.
Due to the sheer volume of the patches, I have addressed the respective patch and the last one, which enables the warning, with addressees for each maintained area so as not to spam people unnecessarily.
If people prefer I carry some through tip, instead, I'll gladly do so - your call.
And, if you think the warning messages need to be more precise, feel free to adjust them before committing.
Thanks!
Borislav Petkov (42):
x86: Check notifier registration return value
xen/x86: Check notifier registration return value
impi: Check notifier registration return value
clk: renesas: Check notifier registration return value
dca: Check notifier registration return value
firmware: Check notifier registration return value drm/i915: Check notifier registration return value
Drivers: hv: vmbus: Check notifier registration return value
iio: proximity: cros_ec: Check notifier registration return value
leds: trigger: Check notifier registration return value
misc: Check notifier registration return value
ethernet: chelsio: Check notifier registration return value
power: reset: Check notifier registration return value
remoteproc: Check notifier registration return value
scsi: target: Check notifier registration return value
USB: Check notifier registration return value
drivers: video: Check notifier registration return value drivers/xen: Check notifier registration return value kernel/hung_task: Check notifier registration return value
rcu: Check notifier registration return value
tracing: Check notifier registration return value
net: fib_notifier: Check notifier registration return value
ASoC: soc-jack: Check notifier registration return value
staging: olpc_dcon: Check notifier registration return value arch/um: Check notifier registration return value
alpha: Check notifier registration return value
bus: brcmstb_gisb: Check notifier registration return value
soc: bcm: brcmstb: pm: pm-arm: Check notifier registration return
value
arm64: Check notifier registration return value soc/tegra: Check notifier registration return value
parisc: Check notifier registration return value macintosh/adb: Check notifier registration return value
mips: Check notifier registration return value
powerpc: Check notifier registration return value
sh: Check notifier registration return value
s390: Check notifier registration return value
sparc: Check notifier registration return value
xtensa: Check notifier registration return value
crypto: ccree - check notifier registration return value EDAC/altera: Check notifier registration return value
power: supply: ab8500: Check notifier registration return value
notifier: Return an error when callback is already registered
arch/alpha/kernel/setup.c | 5 +-- arch/arm64/kernel/setup.c | 6 ++-- arch/mips/kernel/relocate.c | 6 ++-- arch/mips/sgi-ip22/ip22-reset.c | 4 ++- arch/mips/sgi-ip32/ip32-reset.c | 4 ++- arch/parisc/kernel/pdc_chassis.c | 5 +-- arch/powerpc/kernel/setup-common.c | 12 ++++--- arch/s390/kernel/ipl.c | 4 ++- arch/s390/kvm/kvm-s390.c | 7 ++-- arch/sh/kernel/cpu/sh4a/setup-sh7724.c | 11 +++--- arch/sparc/kernel/sstate.c | 6 ++-- arch/um/drivers/mconsole_kern.c | 6 ++-- arch/um/kernel/um_arch.c | 5 +-- arch/x86/kernel/cpu/mce/core.c | 3 +- arch/x86/kernel/cpu/mce/dev-mcelog.c | 3 +- arch/x86/kernel/setup.c | 7 ++-- arch/x86/xen/enlighten.c | 4 ++- arch/xtensa/platforms/iss/setup.c | 3 +- drivers/bus/brcmstb_gisb.c | 6 ++-- drivers/char/ipmi/ipmi_msghandler.c | 3 +- drivers/clk/renesas/clk-div6.c | 4 ++- drivers/clk/renesas/rcar-cpg-lib.c | 4 ++- drivers/crypto/ccree/cc_fips.c | 4 ++- drivers/dca/dca-core.c | 3 +- drivers/edac/altera_edac.c | 6 ++-- drivers/firmware/arm_scmi/notify.c | 3 +- drivers/firmware/google/gsmi.c | 6 ++-- drivers/gpu/drm/i915/gvt/scheduler.c | 6 ++-- drivers/hv/vmbus_drv.c | 4 +-- .../iio/proximity/cros_ec_mkbp_proximity.c | 3 +- drivers/leds/trigger/ledtrig-activity.c | 6 ++-- drivers/leds/trigger/ledtrig-heartbeat.c | 6 ++-- drivers/leds/trigger/ledtrig-panic.c | 4 +-- drivers/macintosh/adbhid.c | 4 +-- drivers/misc/ibmasm/heartbeat.c | 3 +- drivers/misc/pvpanic/pvpanic.c | 3 +- .../chelsio/inline_crypto/chtls/chtls_main.c | 5 ++- drivers/parisc/power.c | 5 +-- drivers/power/reset/ltc2952-poweroff.c | 6 ++-- drivers/power/supply/ab8500_charger.c | 8 ++--- drivers/remoteproc/qcom_common.c | 3 +- drivers/remoteproc/qcom_sysmon.c | 4 ++- drivers/remoteproc/remoteproc_core.c | 4 ++- drivers/s390/char/con3215.c | 5 ++- drivers/s390/char/con3270.c | 5 ++- drivers/s390/char/sclp_con.c | 4 ++- drivers/s390/char/sclp_vt220.c | 4 ++- drivers/s390/char/zcore.c | 4 ++- drivers/soc/bcm/brcmstb/pm/pm-arm.c | 5 +-- drivers/soc/tegra/ari-tegra186.c | 7 ++-- drivers/staging/olpc_dcon/olpc_dcon.c | 4 ++- drivers/target/tcm_fc/tfc_conf.c | 4 ++- drivers/usb/core/notify.c | 3 +- drivers/video/console/dummycon.c | 3 +- drivers/video/fbdev/hyperv_fb.c | 5 +-- drivers/xen/manage.c | 3 +- drivers/xen/xenbus/xenbus_probe.c | 8 +++-- include/linux/notifier.h | 8 ++--- kernel/hung_task.c | 3 +- kernel/notifier.c | 36 ++++++++++--------- kernel/rcu/tree_stall.h | 4 ++- kernel/trace/trace.c | 4 +-- net/core/fib_notifier.c | 4 ++- sound/soc/soc-jack.c | 3 +- 64 files changed, 222 insertions(+), 118 deletions(-)
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 13/42 power: reset: Check notifier registration return value
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/power/reset/ltc2952-poweroff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/power/reset/ltc2952-poweroff.c +4 -2
@@ -279,8 +279,10 @@ static int ltc2952_poweroff_probe(struct platform_device *pdev) pm_power_off = ltc2952_poweroff_kill; data->panic_notifier.notifier_call = ltc2952_poweroff_notify_panic; -atomic_notifier_chain_register (&panic_notifier_list, - &data->panic_notifier); + +if (atomic_notifier_chain_register (&panic_notifier_list, &data->panic_notifier)) +pr_warn ("LTC2952 panic notifier already registered\n" ); +dev_info (&pdev->dev,"probe successful\n" );return 0 ;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 14/42 remoteproc: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/remoteproc/qcom_common.c | 3 ++- drivers/remoteproc/qcom_sysmon.c | 4 +++- drivers/remoteproc/remoteproc_core.c | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-)
drivers/remoteproc/qcom_common.c +2 -1
@@ -390,7 +390,8 @@ void *qcom_register_ssr_notifier(const char *name, struct notifier_block *nb)if (IS_ERR (info))return info; -srcu_notifier_chain_register (&info->notifier_list, nb); +if (srcu_notifier_chain_register (&info->notifier_list, nb)) +pr_warn ("SSR notifier already registered\n" );return &info->notifier_list; }
drivers/remoteproc/qcom_sysmon.c +3 -1
@@ -673,7 +673,9 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,rproc_add_subdev (rproc, &sysmon->subdev); sysmon->nb.notifier_call = sysmon_notify; -blocking_notifier_chain_register (&sysmon_notifiers, &sysmon->nb); + +if (blocking_notifier_chain_register (&sysmon_notifiers, &sysmon->nb)) +pr_warn ("sysmon notifier already registered\n" );mutex_lock (&sysmon_lock);list_add (&sysmon->node, &sysmon_list);
drivers/remoteproc/remoteproc_core.c +3 -1
@@ -2790,7 +2790,9 @@ static int rproc_panic_handler(struct notifier_block *nb, unsigned long event,static void __init rproc_init_panic (void ) { rproc_panic_nb.notifier_call = rproc_panic_handler; -atomic_notifier_chain_register (&panic_notifier_list, &rproc_panic_nb); + +if (atomic_notifier_chain_register (&panic_notifier_list, &rproc_panic_nb)) +pr_warn ("Remote Proc notifier already registered\n" ); } static void __exit rproc_exit_panic(void)
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 25/42 arch/um: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/um/drivers/mconsole_kern.c | 6 ++++-- arch/um/kernel/um_arch.c | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-)
arch/um/drivers/mconsole_kern.c +4 -2
@@ -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 ; }
arch/um/kernel/um_arch.c +3 -2
@@ -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 ();
Signature · 7 lines
2.29.2 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Borislav Petkov
maintainerPATCH 1/42 x86: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/x86/kernel/cpu/mce/core.c | 3 ++- arch/x86/kernel/cpu/mce/dev-mcelog.c | 3 ++- arch/x86/kernel/setup.c | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/mce/core.c +2 -1
@@ -164,7 +164,8 @@ void mce_register_decode_chain(struct notifier_block *nb) nb->priority > MCE_PRIO_HIGHEST))return ; -blocking_notifier_chain_register (&x86_mce_decoder_chain, nb); +if (blocking_notifier_chain_register (&x86_mce_decoder_chain, nb)) +pr_warn ("MCE decoder chain notifier already registered\n" ); }EXPORT_SYMBOL_GPL (mce_register_decode_chain);
arch/x86/kernel/cpu/mce/dev-mcelog.c +2 -1
@@ -281,7 +281,8 @@ static long mce_chrdev_ioctl(struct file *f, unsigned int cmd,void mce_register_injector_chain (struct notifier_block *nb) { -blocking_notifier_chain_register (&mce_injector_chain, nb); +if (blocking_notifier_chain_register (&mce_injector_chain, nb)) +pr_warn ("MCE injector notifier already registered\n" ); }EXPORT_SYMBOL_GPL (mce_register_injector_chain);
arch/x86/kernel/setup.c +5 -2
@@ -1245,8 +1245,11 @@ static struct notifier_block kernel_offset_notifier = {static int __init register_kernel_offset_dumper (void ) { -atomic_notifier_chain_register (&panic_notifier_list, - &kernel_offset_notifier); +int ret =atomic_notifier_chain_register (&panic_notifier_list, + &kernel_offset_notifier); +if (ret) +pr_warn ("Kernel offset dumper notifier already registered\n" ); +return 0 ; }__initcall (register_kernel_offset_dumper);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 15/42 scsi: target: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/target/tcm_fc/tfc_conf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/target/tcm_fc/tfc_conf.c +3 -1
@@ -465,7 +465,9 @@ static int __init ft_init(void)if (ret) goto out_unregister_template; -blocking_notifier_chain_register (&fc_lport_notifier_head, &ft_notifier); +if (blocking_notifier_chain_register (&fc_lport_notifier_head, &ft_notifier)) +pr_warn ("FC lport notifier already registered\n" ); +fc_lport_iterate (ft_lport_add,NULL );return 0 ;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 24/42 staging: olpc_dcon: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/staging/olpc_dcon/olpc_dcon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/olpc_dcon/olpc_dcon.c +3 -1
@@ -653,7 +653,9 @@ static int dcon_probe(struct i2c_client *client, const struct i2c_device_id *id) }register_reboot_notifier (&dcon->reboot_nb); -atomic_notifier_chain_register (&panic_notifier_list, &dcon_panic_nb); + +if (atomic_notifier_chain_register (&panic_notifier_list, &dcon_panic_nb)) +pr_warn ("Panic notifier already registered\n" );return 0 ;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 3/42 impi: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/char/ipmi/ipmi_msghandler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/ipmi/ipmi_msghandler.c +2 -1
@@ -5381,7 +5381,8 @@ static int ipmi_init_msghandler(void)timer_setup (&ipmi_timer, ipmi_timeout,0 );mod_timer (&ipmi_timer, jiffies +IPMI_TIMEOUT_JIFFIES ); -atomic_notifier_chain_register (&panic_notifier_list, &panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, &panic_block)) +pr_warn ("IPMI panic notifier already registered\n" ); initialized = true;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 5/42 dca: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/dca/dca-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dca/dca-core.c +2 -1
@@ -428,7 +428,8 @@ EXPORT_SYMBOL_GPL(unregister_dca_provider);*/ void dca_register_notify (struct notifier_block *nb) { -blocking_notifier_chain_register (&dca_provider_chain, nb); +if (blocking_notifier_chain_register (&dca_provider_chain, nb)) +pr_warn ("dca provider notifier already registered\n" ); }EXPORT_SYMBOL_GPL (dca_register_notify);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 16/42 USB: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/usb/core/notify.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/core/notify.c +2 -1
@@ -28,7 +28,8 @@ static BLOCKING_NOTIFIER_HEAD(usb_notifier_list);*/ void usb_register_notify (struct notifier_block *nb) { -blocking_notifier_chain_register (&usb_notifier_list, nb); +if (blocking_notifier_chain_register (&usb_notifier_list, nb)) +pr_warn ("USB change notifier already registered\n" ); }EXPORT_SYMBOL_GPL (usb_register_notify);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 17/42 drivers: video: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/video/console/dummycon.c | 3 ++- drivers/video/fbdev/hyperv_fb.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/video/console/dummycon.c +2 -1
@@ -36,7 +36,8 @@ void dummycon_register_output_notifier(struct notifier_block *nb) {WARN_CONSOLE_UNLOCKED (); -raw_notifier_chain_register (&dummycon_output_nh, nb); +if (raw_notifier_chain_register (&dummycon_output_nh, nb)) +pr_warn ("dummycon output notifier already registered\n" );if (dummycon_putc_called) nb->notifier_call (nb,0 ,NULL );
drivers/video/fbdev/hyperv_fb.c +3 -2
@@ -1255,8 +1255,9 @@ static int hvfb_probe(struct hv_device *hdev, par->synchronous_fb = false; par->hvfb_panic_nb.notifier_call = hvfb_on_panic; -atomic_notifier_chain_register (&panic_notifier_list, - &par->hvfb_panic_nb); + +if (atomic_notifier_chain_register (&panic_notifier_list, &par->hvfb_panic_nb)) +pr_warn ("Hyper-V FB panic notifier already registered\n" );return 0 ;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 22/42 net: fib_notifier: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- net/core/fib_notifier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/fib_notifier.c +3 -1
@@ -86,7 +86,9 @@ static bool fib_dump_is_consistent(struct net *net, struct notifier_block *nb, {struct fib_notifier_net *fn_net =net_generic (net, fib_notifier_net_id); -atomic_notifier_chain_register (&fn_net->fib_chain, nb); +if (atomic_notifier_chain_register (&fn_net->fib_chain, nb)) +pr_warn ("FIB notifier already registered\n" ); +if (fib_seq ==fib_seq_sum (net))return true;atomic_notifier_chain_unregister (&fn_net->fib_chain, nb);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 33/42 mips: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/mips/kernel/relocate.c | 6 ++++-- arch/mips/sgi-ip22/ip22-reset.c | 4 +++- arch/mips/sgi-ip32/ip32-reset.c | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-)
arch/mips/kernel/relocate.c +4 -2
@@ -459,8 +459,10 @@ static struct notifier_block kernel_location_notifier = {static int __init register_kernel_offset_dumper (void ) { -atomic_notifier_chain_register (&panic_notifier_list, - &kernel_location_notifier); +if (atomic_notifier_chain_register (&panic_notifier_list, + &kernel_location_notifier)) +pr_warn ("Kernel location notifier already registered\n" ); +return 0 ; }__initcall (register_kernel_offset_dumper);
arch/mips/sgi-ip22/ip22-reset.c +3 -1
@@ -196,7 +196,9 @@ static int __init reboot_setup(void) }timer_setup (&blink_timer, blink_timeout,0 ); -atomic_notifier_chain_register (&panic_notifier_list, &panic_block); + +if (atomic_notifier_chain_register (&panic_notifier_list, &panic_block)) +pr_warn ("Panic notifier already registered\n" );return 0 ; }
arch/mips/sgi-ip32/ip32-reset.c +3 -1
@@ -145,7 +145,9 @@ static __init int ip32_reboot_setup(void) pm_power_off = ip32_machine_halt;timer_setup (&blink_timer, blink_timeout,0 ); -atomic_notifier_chain_register (&panic_notifier_list, &panic_block); + +if (atomic_notifier_chain_register (&panic_notifier_list, &panic_block)) +pr_warn ("Panic notifier already registered\n" );return 0 ; }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 18/42 drivers/xen: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/xen/manage.c | 3 ++- drivers/xen/xenbus/xenbus_probe.c | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/xen/manage.c +2 -1
@@ -48,7 +48,8 @@ static RAW_NOTIFIER_HEAD(xen_resume_notifier);void xen_resume_notifier_register (struct notifier_block *nb) { -raw_notifier_chain_register (&xen_resume_notifier, nb); +if (raw_notifier_chain_register (&xen_resume_notifier, nb)) +pr_warn ("Xen resume notifier already registered\n" ); }EXPORT_SYMBOL_GPL (xen_resume_notifier_register);
drivers/xen/xenbus/xenbus_probe.c +5 -3
@@ -731,10 +731,12 @@ int register_xenstore_notifier(struct notifier_block *nb) {int ret =0 ; -if (xenstored_ready >0 ) +if (xenstored_ready >0 ) { ret = nb->notifier_call (nb,0 ,NULL ); -else -blocking_notifier_chain_register (&xenstore_chain, nb); + }else { +if (blocking_notifier_chain_register (&xenstore_chain, nb)) +pr_warn ("Xenstore notifier already registered\n" ); + }return ret; }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 39/42 crypto: ccree - check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/crypto/ccree/cc_fips.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/ccree/cc_fips.c +3 -1
@@ -146,7 +146,9 @@ int cc_fips_init(struct cc_drvdata *p_drvdata)tasklet_init (&fips_h->tasklet, fips_dsr, (unsigned long )p_drvdata); fips_h->drvdata = p_drvdata; fips_h->nb.notifier_call = cc_ree_fips_failure; -atomic_notifier_chain_register (&fips_fail_notif_chain, &fips_h->nb); + +if (atomic_notifier_chain_register (&fips_fail_notif_chain, &fips_h->nb)) +pr_warn ("Failure notifier already registered\n" );cc_tee_handle_fips_error (p_drvdata);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 35/42 sh: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/sh/kernel/cpu/sh4a/setup-sh7724.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +7 -4
@@ -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" ); -atomic_notifier_chain_register (&sh_mobile_post_sleep_notifier_list, - &sh7724_post_sleep_notifier);return 0 ; }arch_initcall (sh7724_sleep_setup);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 36/42 s390: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/s390/kernel/ipl.c | 4 +++- arch/s390/kvm/kvm-s390.c | 7 +++++-- drivers/s390/char/con3215.c | 5 ++++- drivers/s390/char/con3270.c | 5 ++++- drivers/s390/char/sclp_con.c | 4 +++- drivers/s390/char/sclp_vt220.c | 4 +++- drivers/s390/char/zcore.c | 4 +++- 7 files changed, 25 insertions(+), 8 deletions(-)
arch/s390/kernel/ipl.c +3 -1
@@ -2069,7 +2069,9 @@ void __init setup_ipl(void)/* We have no info to copy */ break ; } -atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb); + +if (atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb)) +pr_warn ("Panic notifier already registered\n" ); }void s390_reset_system (void )
arch/s390/kvm/kvm-s390.c +5 -2
@@ -325,8 +325,11 @@ int kvm_arch_hardware_setup(void *opaque)gmap_register_pte_notifier (&gmap_notifier); vsie_gmap_notifier.notifier_call = kvm_s390_vsie_gmap_notifier;gmap_register_pte_notifier (&vsie_gmap_notifier); -atomic_notifier_chain_register (&s390_epoch_delta_notifier, - &kvm_clock_notifier); + +if (atomic_notifier_chain_register (&s390_epoch_delta_notifier, + &kvm_clock_notifier)) +pr_warn ("KVM clock notifier already registered\n" ); +return 0 ; }
drivers/s390/char/con3215.c +4 -1
@@ -865,7 +865,10 @@ static int __init con3215_init(void) raw3215[0 ] =NULL ;return -ENODEV ; } -atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb); + +if (atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb)) +pr_warn ("Panic notifier already registered\n" ); +register_reboot_notifier (&on_reboot_nb);register_console (&con3215);return 0 ;
drivers/s390/char/con3270.c +4 -1
@@ -641,7 +641,10 @@ con3270_init(void) condev->cline->len =0 ;con3270_create_status (condev); condev->input =alloc_string (&condev->freemem,80 ); -atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb); + +if (atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb)) +pr_warn ("Panic notifier already registered\n" ); +register_reboot_notifier (&on_reboot_nb);register_console (&con3270);return 0 ;
drivers/s390/char/sclp_con.c +3 -1
@@ -285,7 +285,9 @@ sclp_console_init(void)timer_setup (&sclp_con_timer, sclp_console_timeout,0 );/* enable printk-access to this driver */ -atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb); +if (atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb)) +pr_warn ("Panic notifier already registered\n" ); +register_reboot_notifier (&on_reboot_nb);register_console (&sclp_console);return 0 ;
drivers/s390/char/sclp_vt220.c +3 -1
@@ -836,7 +836,9 @@ sclp_vt220_con_init(void)if (rc)return rc;/* Attach linux console */ -atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb); +if (atomic_notifier_chain_register (&panic_notifier_list, &on_panic_nb)) +pr_warn ("Panic notifier already registered\n" ); +register_reboot_notifier (&on_reboot_nb);register_console (&sclp_vt220_console);return 0 ;
drivers/s390/char/zcore.c +3 -1
@@ -323,7 +323,9 @@ static int __init zcore_init(void) NULL, &zcore_hsa_fops);register_reboot_notifier (&zcore_reboot_notifier); -atomic_notifier_chain_register (&panic_notifier_list, &zcore_on_panic_notifier); + +if (atomic_notifier_chain_register (&panic_notifier_list, &zcore_on_panic_notifier)) +pr_warn ("Panic notifier already registered\n" );return 0 ; fail:
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 37/42 sparc: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/sparc/kernel/sstate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/sparc/kernel/sstate.c +4 -2
@@ -106,8 +106,10 @@ static int __init sstate_init(void)do_set_sstate (HV_SOFT_STATE_TRANSITION , booting_msg); -atomic_notifier_chain_register (&panic_notifier_list, - &sstate_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, + &sstate_panic_block)) +pr_warn ("Soft state panic notifier already registered\n" ); +register_reboot_notifier (&sstate_reboot_notifier);return 0 ;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 20/42 rcu: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- kernel/rcu/tree_stall.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/rcu/tree_stall.h +3 -1
@@ -101,7 +101,9 @@ static struct notifier_block rcu_panic_block = {static int __init check_cpu_stall_init (void ) { -atomic_notifier_chain_register (&panic_notifier_list, &rcu_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, &rcu_panic_block)) +pr_warn ("RCU warning suppress notifier already registered\n" ); +return 0 ; }early_initcall (check_cpu_stall_init);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 23/42 ASoC: soc-jack: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- sound/soc/soc-jack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/soc-jack.c +2 -1
@@ -181,7 +181,8 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_add_pins);void snd_soc_jack_notifier_register (struct snd_soc_jack *jack,struct notifier_block *nb) { -blocking_notifier_chain_register (&jack->notifier, nb); +if (blocking_notifier_chain_register (&jack->notifier, nb)) +pr_warn ("Jack status notifier already registered\n" ); }EXPORT_SYMBOL_GPL (snd_soc_jack_notifier_register);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 7/42 drm/i915: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/gpu/drm/i915/gvt/scheduler.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/scheduler.c +4 -2
@@ -1277,8 +1277,10 @@ int intel_gvt_init_workload_scheduler(struct intel_gvt *gvt) gvt->shadow_ctx_notifier_block[i].notifier_call = shadow_context_status_change; -atomic_notifier_chain_register (&engine->context_status_notifier, - &gvt->shadow_ctx_notifier_block[i]); + +if (atomic_notifier_chain_register (&engine->context_status_notifier, + &gvt->shadow_ctx_notifier_block[i])) +pr_warn ("Context status notifier %d already registered\n" , i); }return 0 ;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 31/42 parisc: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/parisc/kernel/pdc_chassis.c | 5 +++-- drivers/parisc/power.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
arch/parisc/kernel/pdc_chassis.c +3 -2
@@ -135,8 +135,9 @@ void __init parisc_pdc_chassis_init(void) PDC_CHASSIS_VER);/* initialize panic notifier chain */ -atomic_notifier_chain_register (&panic_notifier_list, - &pdc_chassis_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, + &pdc_chassis_panic_block)) +printk (KERN_WARNING "Panic notifier already registered\n" );/* initialize reboot notifier chain */ register_reboot_notifier (&pdc_chassis_reboot_block);
drivers/parisc/power.c +3 -2
@@ -230,8 +230,9 @@ static int __init power_init(void) }/* Register a call for panic conditions. */ -atomic_notifier_chain_register (&panic_notifier_list, - &parisc_panic_block); + +if (atomic_notifier_chain_register (&panic_notifier_list, &parisc_panic_block)) +pr_warn ("Panic notifier already registered\n" );return 0 ; }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 41/42 power: supply: ab8500: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/power/supply/ab8500_charger.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/power/supply/ab8500_charger.c +4 -4
@@ -3644,10 +3644,10 @@ static int ab8500_charger_probe(struct platform_device *pdev) }/* Notifier for external charger enabling */ -if (!di->ac_chg.enabled) -blocking_notifier_chain_register ( - &charger_notifier_list, &charger_nb); - +if (!di->ac_chg.enabled) { +if (blocking_notifier_chain_register (&charger_notifier_list, &charger_nb)) +pr_warn ("Charger notifier already registered\n" ); + } di->usb_phy =usb_get_phy (USB_PHY_TYPE_USB2 );if (IS_ERR_OR_NULL (di->usb_phy)) {
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 40/42 EDAC/altera: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/edac/altera_edac.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/edac/altera_edac.c +4 -2
@@ -2125,8 +2125,10 @@ static int altr_edac_a10_probe(struct platform_device *pdev)int dberror, err_addr; edac->panic_notifier.notifier_call = s10_edac_dberr_handler; -atomic_notifier_chain_register (&panic_notifier_list, - &edac->panic_notifier); + +if (atomic_notifier_chain_register (&panic_notifier_list, + &edac->panic_notifier)) +pr_warn ("Panic notifier already registered\n" );/* Printout a message if uncorrectable error previously. */ regmap_read(edac->ecc_mgr_map, S10_SYSMGR_UE_VAL_OFST,
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 6/42 firmware: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/firmware/arm_scmi/notify.c | 3 ++- drivers/firmware/google/gsmi.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/firmware/arm_scmi/notify.c +2 -1
@@ -1358,7 +1358,8 @@ static int scmi_notifier_register(const struct scmi_handle *handle,if (!hndl)return -EINVAL ; -blocking_notifier_chain_register (&hndl->chain, nb); +if (blocking_notifier_chain_register (&hndl->chain, nb)) +pr_warn ("SCMI notifier already registered\n" );/* Enable events for not pending handlers */ if (!IS_HNDL_PENDING (hndl)) {
drivers/firmware/google/gsmi.c +4 -2
@@ -1030,8 +1030,10 @@ static __init int gsmi_init(void)register_reboot_notifier (&gsmi_reboot_notifier);register_die_notifier (&gsmi_die_notifier); -atomic_notifier_chain_register (&panic_notifier_list, - &gsmi_panic_notifier); + +if (atomic_notifier_chain_register (&panic_notifier_list, + &gsmi_panic_notifier)) +pr_warn ("gsmi panic notifier already registered\n" );printk (KERN_INFO "gsmi version " DRIVER_VERSION " loaded\n" );
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 12/42 ethernet: chelsio: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- .../net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c +4 -1
@@ -39,7 +39,10 @@ static uint send_page_order = (14 - PAGE_SHIFT < 0) ? 0 : 14 - PAGE_SHIFT;static void register_listen_notifier (struct notifier_block *nb) {mutex_lock (¬ify_mutex); -raw_notifier_chain_register (&listen_notify_list, nb); + +if (raw_notifier_chain_register (&listen_notify_list, nb)) +pr_warn ("chtls listen notifier already registered\n" ); +mutex_unlock (¬ify_mutex); }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 11/42 misc: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/misc/ibmasm/heartbeat.c | 3 ++- drivers/misc/pvpanic/pvpanic.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/misc/ibmasm/heartbeat.c +2 -1
@@ -39,7 +39,8 @@ static struct notifier_block panic_notifier = { panic_happened, NULL, 1 };void ibmasm_register_panic_notifier (void ) { -atomic_notifier_chain_register (&panic_notifier_list, &panic_notifier); +if (atomic_notifier_chain_register (&panic_notifier_list, &panic_notifier)) +pr_warn ("IBM ASM panic notifier already registered\n" ); }void ibmasm_unregister_panic_notifier (void )
drivers/misc/pvpanic/pvpanic.c +2 -1
@@ -95,7 +95,8 @@ static int pvpanic_init(void)INIT_LIST_HEAD (&pvpanic_list);spin_lock_init (&pvpanic_lock); -atomic_notifier_chain_register (&panic_notifier_list, &pvpanic_panic_nb); +if (atomic_notifier_chain_register (&panic_notifier_list, &pvpanic_panic_nb)) +pr_warn ("PV panic notifier already registered\n" );return 0 ; }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 32/42 macintosh/adb: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/macintosh/adbhid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/macintosh/adbhid.c +2 -2
@@ -1262,8 +1262,8 @@ static int __init adbhid_init(void)adbhid_probe (); -blocking_notifier_chain_register (&adb_client_list, - &adbhid_adb_notifier); +if (blocking_notifier_chain_register (&adb_client_list, &adbhid_adb_notifier)) +pr_warn ("ADB message notifier already registered\n" );return 0 ; }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 29/42 arm64: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/arm64/kernel/setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm64/kernel/setup.c +4 -2
@@ -440,8 +440,10 @@ static struct notifier_block arm64_panic_block = {static int __init register_arm64_panic_block (void ) { -atomic_notifier_chain_register (&panic_notifier_list, - &arm64_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, + &arm64_panic_block)) +pr_warn ("Panic notifier already registered\n" ); +return 0 ; }device_initcall (register_arm64_panic_block);
Signature · 7 lines
2.29.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Borislav Petkov
maintainerPATCH 27/42 bus: brcmstb_gisb: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/bus/brcmstb_gisb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bus/brcmstb_gisb.c +4 -2
@@ -490,8 +490,10 @@ static int __init brcmstb_gisb_arb_probe(struct platform_device *pdev)if (list_is_singular (&brcmstb_gisb_arb_device_list)) {register_die_notifier (&gisb_die_notifier); -atomic_notifier_chain_register (&panic_notifier_list, - &gisb_panic_notifier); + +if (atomic_notifier_chain_register (&panic_notifier_list, + &gisb_panic_notifier)) +pr_warn ("GISB Panic notifier already registered\n" ); } dev_info(&pdev->dev, "registered irqs: %d, %d\n",
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 19/42 kernel/hung_task: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- kernel/hung_task.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/hung_task.c +2 -1
@@ -304,7 +304,8 @@ static int watchdog(void *dummy)static int __init hung_task_init (void ) { -atomic_notifier_chain_register (&panic_notifier_list, &panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, &panic_block)) +pr_warn ("Hung task notifier already registered\n" );/* Disable hung task detector on suspend */ pm_notifier (hungtask_pm_notify,0 );
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 21/42 tracing: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- kernel/trace/trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace.c +2 -2
@@ -10064,8 +10064,8 @@ __init static int tracer_alloc_buffers(void)/* All seems OK, enable tracing */ tracing_disabled =0 ; -atomic_notifier_chain_register (&panic_notifier_list, - &trace_panic_notifier); +if (atomic_notifier_chain_register (&panic_notifier_list, &trace_panic_notifier)) +pr_warn ("Trace panic notifier already registered\n" );register_die_notifier (&trace_die_notifier);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 28/42 soc: bcm: brcmstb: pm: pm-arm: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/soc/bcm/brcmstb/pm/pm-arm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/soc/bcm/brcmstb/pm/pm-arm.c +3 -2
@@ -802,8 +802,9 @@ static int brcmstb_pm_probe(struct platform_device *pdev) goto out; } -atomic_notifier_chain_register (&panic_notifier_list, - &brcmstb_pm_panic_nb); +if (atomic_notifier_chain_register (&panic_notifier_list, + &brcmstb_pm_panic_nb)) +pr_warn ("Panic notifier already registered\n" ); pm_power_off = brcmstb_pm_poweroff;suspend_set_ops (&brcmstb_pm_ops);
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 30/42 soc/tegra: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- drivers/soc/tegra/ari-tegra186.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/soc/tegra/ari-tegra186.c +5 -2
@@ -72,8 +72,11 @@ static struct notifier_block tegra186_ari_panic_nb = {static int __init tegra186_ari_init (void ) { -if (of_machine_is_compatible ("nvidia,tegra186" )) -atomic_notifier_chain_register (&panic_notifier_list, &tegra186_ari_panic_nb); +if (of_machine_is_compatible ("nvidia,tegra186" )) { +if (atomic_notifier_chain_register (&panic_notifier_list, + &tegra186_ari_panic_nb)) +pr_warn ("Panic notifier already registered\n" ); + }return 0 ; }
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 34/42 powerpc: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/powerpc/kernel/setup-common.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/powerpc/kernel/setup-common.c +8 -4
@@ -725,14 +725,18 @@ static struct notifier_block kernel_offset_notifier = {void __init setup_panic (void ) { -if (IS_ENABLED (CONFIG_RANDOMIZE_BASE ) &&kaslr_offset () >0 ) -atomic_notifier_chain_register (&panic_notifier_list, - &kernel_offset_notifier); +if (IS_ENABLED (CONFIG_RANDOMIZE_BASE ) &&kaslr_offset () >0 ) { +if (atomic_notifier_chain_register (&panic_notifier_list, + &kernel_offset_notifier)) +pr_warn ("Kernel offset notifier already registered\n" ); + }/* PPC64 always does a hard irq disable in its panic handler */ if (!IS_ENABLED (CONFIG_PPC64 ) && !ppc_md.panic)return ; -atomic_notifier_chain_register (&panic_notifier_list, &ppc_panic_block); + +if (atomic_notifier_chain_register (&panic_notifier_list, &ppc_panic_block)) +pr_warn ("Panic notifier already registered\n" ); }#ifdef CONFIG_CHECK_CACHE_COHERENCY
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 38/42 xtensa: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
--- arch/xtensa/platforms/iss/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/xtensa/platforms/iss/setup.c +2 -1
@@ -81,5 +81,6 @@ void __init platform_setup(char **p_cmdline) } } -atomic_notifier_chain_register (&panic_notifier_list, &iss_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, &iss_panic_block)) +pr_warn ("Panic notifier already registered\n" ); }
Signature · 1 line
2.29.2
Borislav Petkov
maintainercover notifiers: Return an error when callback is already registered
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Hi all,
this is a huge patchset for something which is really trivial - it changes the notifier registration routines to return an error value if a notifier callback is already present on the respective list of callbacks. For more details scroll to the last patch.
Everything before it is converting the callers to check the return value of the registration routines and issue a warning, instead of the WARN() notifier_chain_register() does now.
Before the last patch has been applied, though, that checking is a NOP which would make the application of those patches trivial - every maintainer can pick a patch at her/his discretion - only the last one enables the build warnings and that one will be queued only after the preceding patches have all been merged so that there are no build warnings.
Due to the sheer volume of the patches, I have addressed the respective patch and the last one, which enables the warning, with addressees for each maintained area so as not to spam people unnecessarily.
If people prefer I carry some through tip, instead, I'll gladly do so - your call.
And, if you think the warning messages need to be more precise, feel free to adjust them before committing.
Thanks!
Borislav Petkov (42):
x86: Check notifier registration return value
xen/x86: Check notifier registration return value
impi: Check notifier registration return value
clk: renesas: Check notifier registration return value
dca: Check notifier registration return value
firmware: Check notifier registration return value drm/i915: Check notifier registration return value
Drivers: hv: vmbus: Check notifier registration return value
iio: proximity: cros_ec: Check notifier registration return value
leds: trigger: Check notifier registration return value
misc: Check notifier registration return value
ethernet: chelsio: Check notifier registration return value
power: reset: Check notifier registration return value
remoteproc: Check notifier registration return value
scsi: target: Check notifier registration return value
USB: Check notifier registration return value
drivers: video: Check notifier registration return value drivers/xen: Check notifier registration return value kernel/hung_task: Check notifier registration return value
rcu: Check notifier registration return value
tracing: Check notifier registration return value
net: fib_notifier: Check notifier registration return value
ASoC: soc-jack: Check notifier registration return value
staging: olpc_dcon: Check notifier registration return value arch/um: Check notifier registration return value
alpha: Check notifier registration return value
bus: brcmstb_gisb: Check notifier registration return value
soc: bcm: brcmstb: pm: pm-arm: Check notifier registration return
value
arm64: Check notifier registration return value soc/tegra: Check notifier registration return value
parisc: Check notifier registration return value macintosh/adb: Check notifier registration return value
mips: Check notifier registration return value
powerpc: Check notifier registration return value
sh: Check notifier registration return value
s390: Check notifier registration return value
sparc: Check notifier registration return value
xtensa: Check notifier registration return value
crypto: ccree - check notifier registration return value EDAC/altera: Check notifier registration return value
power: supply: ab8500: Check notifier registration return value
notifier: Return an error when callback is already registered
arch/alpha/kernel/setup.c | 5 +-- arch/arm64/kernel/setup.c | 6 ++-- arch/mips/kernel/relocate.c | 6 ++-- arch/mips/sgi-ip22/ip22-reset.c | 4 ++- arch/mips/sgi-ip32/ip32-reset.c | 4 ++- arch/parisc/kernel/pdc_chassis.c | 5 +-- arch/powerpc/kernel/setup-common.c | 12 ++++--- arch/s390/kernel/ipl.c | 4 ++- arch/s390/kvm/kvm-s390.c | 7 ++-- arch/sh/kernel/cpu/sh4a/setup-sh7724.c | 11 +++--- arch/sparc/kernel/sstate.c | 6 ++-- arch/um/drivers/mconsole_kern.c | 6 ++-- arch/um/kernel/um_arch.c | 5 +-- arch/x86/kernel/cpu/mce/core.c | 3 +- arch/x86/kernel/cpu/mce/dev-mcelog.c | 3 +- arch/x86/kernel/setup.c | 7 ++-- arch/x86/xen/enlighten.c | 4 ++- arch/xtensa/platforms/iss/setup.c | 3 +- drivers/bus/brcmstb_gisb.c | 6 ++-- drivers/char/ipmi/ipmi_msghandler.c | 3 +- drivers/clk/renesas/clk-div6.c | 4 ++- drivers/clk/renesas/rcar-cpg-lib.c | 4 ++- drivers/crypto/ccree/cc_fips.c | 4 ++- drivers/dca/dca-core.c | 3 +- drivers/edac/altera_edac.c | 6 ++-- drivers/firmware/arm_scmi/notify.c | 3 +- drivers/firmware/google/gsmi.c | 6 ++-- drivers/gpu/drm/i915/gvt/scheduler.c | 6 ++-- drivers/hv/vmbus_drv.c | 4 +-- .../iio/proximity/cros_ec_mkbp_proximity.c | 3 +- drivers/leds/trigger/ledtrig-activity.c | 6 ++-- drivers/leds/trigger/ledtrig-heartbeat.c | 6 ++-- drivers/leds/trigger/ledtrig-panic.c | 4 +-- drivers/macintosh/adbhid.c | 4 +-- drivers/misc/ibmasm/heartbeat.c | 3 +- drivers/misc/pvpanic/pvpanic.c | 3 +- .../chelsio/inline_crypto/chtls/chtls_main.c | 5 ++- drivers/parisc/power.c | 5 +-- drivers/power/reset/ltc2952-poweroff.c | 6 ++-- drivers/power/supply/ab8500_charger.c | 8 ++--- drivers/remoteproc/qcom_common.c | 3 +- drivers/remoteproc/qcom_sysmon.c | 4 ++- drivers/remoteproc/remoteproc_core.c | 4 ++- drivers/s390/char/con3215.c | 5 ++- drivers/s390/char/con3270.c | 5 ++- drivers/s390/char/sclp_con.c | 4 ++- drivers/s390/char/sclp_vt220.c | 4 ++- drivers/s390/char/zcore.c | 4 ++- drivers/soc/bcm/brcmstb/pm/pm-arm.c | 5 +-- drivers/soc/tegra/ari-tegra186.c | 7 ++-- drivers/staging/olpc_dcon/olpc_dcon.c | 4 ++- drivers/target/tcm_fc/tfc_conf.c | 4 ++- drivers/usb/core/notify.c | 3 +- drivers/video/console/dummycon.c | 3 +- drivers/video/fbdev/hyperv_fb.c | 5 +-- drivers/xen/manage.c | 3 +- drivers/xen/xenbus/xenbus_probe.c | 8 +++-- include/linux/notifier.h | 8 ++--- kernel/hung_task.c | 3 +- kernel/notifier.c | 36 ++++++++++--------- kernel/rcu/tree_stall.h | 4 ++- kernel/trace/trace.c | 4 +-- net/core/fib_notifier.c | 4 ++- sound/soc/soc-jack.c | 3 +- 64 files changed, 222 insertions(+), 118 deletions(-)
Signature · 1 line
2.29.2
Johannes Berg
maintainerRe: [PATCH v0 25/42] arch/um: Check notifier registration return value
In reply to Borislav PetkovQuoted 28 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>---
arch/um/drivers/mconsole_kern.c | 6 ++++--
arch/um/kernel/um_arch.c | 5 +++--2 files changed, 7 insertions(+), 4 deletions(-)arch/um/drivers/mconsole_kern.c +0
-0@@ -856,8 +856,10 @@ static struct notifier_block panic_exit_notifier = {static int
add_notifier(void)
{arch/um/drivers/mconsole_kern.c +4
-2-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" ); +
Quoted 1 line
return 0;
Maybe it should just return it? I don't see how this is ever possible, since it's an initcall.
johannes
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Borislav Petkov
maintainerRe: [PATCH v0 25/42] arch/um: Check notifier registration return value
Quoted 2 lines · Johannes Berg
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...
Signature · 9 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-umJohannes Berg
maintainerRe: [PATCH v0 25/42] arch/um: Check notifier registration return value
Quoted 6 lines · Borislav Petkov
Quoted 2 lines · Johannes Berg
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 :)
Quoted 2 lines
I can do that if it is preferred...
No strong opinion either way.
johannes
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH v0 08/42] Drivers: hv: vmbus: Check notifier registration return value
In reply to Borislav PetkovQuoted 8 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>
Quoted 22 lines
--- drivers/hv/vmbus_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/hv/vmbus_drv.c +2
-2@@ -1574,8 +1574,8 @@ static int vmbus_bus_init(void)* the VMbus channel connection to prevent any VMbus * activity after the VM panics. */ -atomic_notifier_chain_register (&panic_notifier_list, - &hyperv_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, &hyperv_panic_block)) +pr_warn ("VMBus panic notifier already registered\n" );vmbus_request_offers ();Signature · 1 line
2.29.2
Re: [PATCH v0 17/42] drivers: video: Check notifier registration return value
In reply to Borislav PetkovQuoted 9 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Borislav Petkov
maintainerRe: [PATCH v0 08/42] Drivers: hv: vmbus: Check notifier registration return value
In reply to Wei LiuQuoted 11 lines · Wei Liu
Quoted 8 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>Acked-by Wei Liu <[email protected]>
Thanks.
I assume your ack means, I can take the two through tip.
Alternatively, you can take 'em too, if you prefer, as there's no dependency, see here:
https://lore.kernel.org/r/[email protected]
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteWei Liu
maintainerRe: [PATCH v0 08/42] Drivers: hv: vmbus: Check notifier registration return value
Quoted 8 lines · Borislav Petkov
Quoted 7 lines · Wei Liu
Quoted 6 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Borislav Petkov <[email protected]>Acked-by Wei Liu <[email protected]>Thanks.
I assume your ack means, I can take the two through tip.
Yes please take them through tip. I should've been clearer on this. Sorry.
Wei.
Borislav Petkov
maintainerRe: [PATCH v0 08/42] Drivers: hv: vmbus: Check notifier registration return value
Quoted 2 lines · Wei Liu
Yes please take them through tip. I should've been clearer on this. Sorry.
No worries - I'll do so.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v0 35/42] sh: Check notifier registration return value
In reply to Borislav PetkovHi Borislav,
Quoted 7 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>
Thanks for your patch!
Quoted 5 lines
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +0
-0@@ -1277,11 +1277,14 @@ static struct notifier_block sh7724_post_sleep_notifier = {static int __init sh7724_sleep_setup (void )
arch/sh/kernel/cpu/sh4a/setup-sh7724.c static struct notifier_block sh7724_post_sleep_notifier = { · line 1286
Quoted 10 lines
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +7
-2{ -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?
arch/sh/kernel/cpu/sh4a/setup-sh7724.c static struct notifier_block sh7724_post_sleep_notifier = { · line 1290
Quoted 6 lines
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +0
-2-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 -- [email protected]
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
Borislav Petkov
maintainerRe: [PATCH v0 35/42] sh: Check notifier registration return value
Quoted 1 line · Geert Uytterhoeven
Do you think these can actually fail?
Hmm, maybe you missed the 0th message. Does this explain it:
https://lore.kernel.org/r/[email protected]
?
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v0 35/42] sh: Check notifier registration return value
Hi Borislav,
Quoted 8 lines · Borislav Petkov
Quoted 1 line · Geert Uytterhoeven
Do you think these can actually fail?
Hmm, maybe you missed the 0th message. Does this explain it:
https://lore.kernel.org/r/[email protected]
?
Thanks, but that still doesn't explain why we need to add the check, for something that IMHO cannot fail, in a caller that cannot do anything in the very unlikely event that he call would ever start to fail?
The clue is the addition of __must_check in "[PATCH v0 42/42] notifier:
Return an error when callback is already registered"
(https://lore.kernel.org/all/[email protected]/).
I'll reply to that one...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Re: [PATCH v0 16/42] USB: Check notifier registration return value
In reply to Borislav PetkovQuoted 3 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
This is a rather misleading description. The patch does exactly the
opposite: It _adds_ a homegrown notifier registration check. (Homegrown in the sense that the check is made by the individual caller rather than being centralized in the routine being called.)
Alan Stern
Quoted 25 lines
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>--- drivers/usb/core/notify.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/usb/core/notify.c +2
-1@@ -28,7 +28,8 @@ static BLOCKING_NOTIFIER_HEAD(usb_notifier_list);*/ void usb_register_notify (struct notifier_block *nb) { -blocking_notifier_chain_register (&usb_notifier_list, nb); +if (blocking_notifier_chain_register (&usb_notifier_list, nb)) +pr_warn ("USB change notifier already registered\n" ); }EXPORT_SYMBOL_GPL (usb_register_notify);Signature · 1 line
2.29.2
Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered
In reply to Borislav PetkovHi Borislav,
Quoted 20 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
The notifier registration routine doesn't return a proper error value when a callback has already been registered, leading people to track whether that registration has happened at the call site:
https://lore.kernel.org/amd-gfx/[email protected]/
Which is unnecessary.
Return
-EEXISTto signal that case so that callers can act accordingly. Enforce callers to check the return value, leading to loud screaming during build:arch/x86/kernel/cpu/mce/core.c: In function ‘mce_register_decode_chain’: arch/x86/kernel/cpu/mce/core.c:167:2: error: ignoring return value of \ ‘blocking_notifier_chain_register’, declared with attribute warn_unused_result [-Werror=unused-result] blocking_notifier_chain_register(&x86_mce_decoder_chain, nb); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines
Drop the WARN too, while at it.
Suggested-by Thomas Gleixner <[email protected]>Signed-off-by Borislav Petkov <[email protected]>
Thanks for your patch!
Quoted 8 lines
include/linux/notifier.h +1
-1@@ -141,13 +141,13 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);#ifdef __KERNEL__ -extern int atomic_notifier_chain_register(struct atomic_notifier_head *nh, +extern int __must_check atomic_notifier_chain_register(struct atomic_notifier_head *nh,
include/linux/notifier.h extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); · line 151
Quoted 10 lines
include/linux/notifier.h +3
-3struct notifier_block *nb); -extern int blocking_notifier_chain_register (struct blocking_notifier_head *nh, +extern int __must_check blocking_notifier_chain_register (struct blocking_notifier_head *nh,struct notifier_block *nb); -extern int raw_notifier_chain_register (struct raw_notifier_head *nh, +extern int __must_check raw_notifier_chain_register (struct raw_notifier_head *nh,struct notifier_block *nb); -extern int srcu_notifier_chain_register (struct srcu_notifier_head *nh, +extern int __must_check srcu_notifier_chain_register (struct srcu_notifier_head *nh,struct notifier_block *nb);
I think the addition of __must_check is overkill, leading to the addition of useless error checks and message printing. Many callers call this where it cannot fail, and where nothing can be done in the very unlikely event that the call would ever start to fail.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Borislav Petkov
maintainerRe: [PATCH v0 16/42] USB: Check notifier registration return value
In reply to Alan SternQuoted 4 lines · Alan Stern
This is a rather misleading description. The patch does exactly the
opposite: It _adds_ a homegrown notifier registration check. (Homegrown in the sense that the check is made by the individual caller rather than being centralized in the routine being called.)
See the 0th message - there is a link to another example of what I mean with "homegrown" but I see your point.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v0 04/42] clk: renesas: Check notifier registration return value
In reply to Borislav PetkovHi Borislav,
Thanks for your patch!
Quoted 3 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
Which homegrown notifier registration check is avoided? IIANM, you're adding a homegrown notifier registration check?
Quoted 7 lines
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>
drivers/clk/renesas/clk-div6.c struct clk * __init cpg_div6_register(const char *name, · line 311
Quoted 7 lines
drivers/clk/renesas/clk-div6.c +3
-1@@ -306,7 +306,9 @@ struct clk * __init cpg_div6_register(const char *name,if (notifiers) { clock->nb.notifier_call = cpg_div6_clock_notifier_call; -raw_notifier_chain_register (notifiers, &clock->nb); + +if (raw_notifier_chain_register (notifiers, &clock->nb)) +pr_warn ("CPG DIV6 clock notifier already registered\n" );
A duplicate registration cannot happen, as the notifier is freshly allocated.
Quoted 8 lines
drivers/clk/renesas/clk-div6.c +0
-0}return clk;drivers/clk/renesas/rcar-cpg-lib.c +0
-0
drivers/clk/renesas/rcar-cpg-lib.c void cpg_simple_notifier_register(struct raw_notifier_head *notifiers, · line 64
Quoted 7 lines
drivers/clk/renesas/rcar-cpg-lib.c +3
-1@@ -59,7 +59,9 @@ void cpg_simple_notifier_register(struct raw_notifier_head *notifiers, struct cpg_simple_notifier *csn) { csn->nb.notifier_call = cpg_simple_notifier_call; -raw_notifier_chain_register (notifiers, &csn->nb); + +if (raw_notifier_chain_register (notifiers, &csn->nb)) +pr_warn ("CPG notifier already registered\n" );
A duplicate registration cannot happen, as the notifier is freshly allocated.
drivers/clk/renesas/rcar-cpg-lib.c void cpg_simple_notifier_register(struct raw_notifier_head *notifiers, · line 66
Quoted 2 lines
drivers/clk/renesas/rcar-cpg-lib.c +0
-0}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Quoted 4 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Hi all,
Quoted 8 lines
this is a huge patchset for something which is really trivial - it changes the notifier registration routines to return an error value if a notifier callback is already present on the respective list of callbacks. For more details scroll to the last patch.
Everything before it is converting the callers to check the return value of the registration routines and issue a warning, instead of the
WARN()notifier_chain_register()does now.
What reason is there for moving the check into the callers? It seems like pointless churn. Why not add the error return code, change the WARN to pr_warn, and leave the callers as they are? Wouldn't that end up having exactly the same effect?
For that matter, what sort of remedial action can a caller take if the return code is -EEXIST? Is there any point in forcing callers to check the return code if they can't do anything about it?
Quoted 6 lines
Before the last patch has been applied, though, that checking is a NOP which would make the application of those patches trivial - every maintainer can pick a patch at her/his discretion - only the last one enables the build warnings and that one will be queued only after the preceding patches have all been merged so that there are no build warnings.
Why should there be _any_ build warnings? The real problem occurs when a notifier callback is added twice, not when a caller fails to check the return code. Double-registration is not the sort of thing that can be detected at build time.
Alan Stern
Quoted 11 lines
Due to the sheer volume of the patches, I have addressed the respective patch and the last one, which enables the warning, with addressees for each maintained area so as not to spam people unnecessarily.
If people prefer I carry some through tip, instead, I'll gladly do so - your call.
And, if you think the warning messages need to be more precise, feel free to adjust them before committing.
Thanks!
Borislav Petkov
maintainerRe: [PATCH v0 42/42] notifier: Return an error when callback is already registered
In reply to Geert UytterhoevenQuoted 2 lines · Geert Uytterhoeven
I think the addition of
__must_checkis overkill, leading to the addition of useless error checks and message printing.
See the WARN in notifier_chain_register() - it will already do "message printing".
Quoted 3 lines
Many callers call this where it cannot fail, and where nothing can be done in the very unlikely event that the call would ever start to fail.
This is an attempt to remove this WARN() hack in notifier_chain_register() and have the function return a proper error value instead of this "Currently always returns zero." which is bad design.
Some of the registration functions around the tree check that retval and some don't. So if "it cannot fail" those registration either should not return a value or callers should check that return value - what we have now doesn't make a whole lot of sense.
Oh, and then fixing this should avoid stuff like:
+ if (notifier_registered == false) {
+ mce_register_decode_chain(&amdgpu_bad_page_nb);
+ notifier_registered = true;
+ }
from propagating in the code.
The other idea I have is to add another indirection in notifier_chain_register() which will check the *proper* return value of a lower level __notifier_chain_register() and then issue that warning. That would definitely avoid touch so many call sites.
Bottom line is: what we have now needs cleaning up.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerQuoted 8 lines · Alan Stern
What reason is there for moving the check into the callers? It seems like pointless churn. Why not add the error return code, change the WARN to
pr_warn, and leave the callers as they are? Wouldn't that end up having exactly the same effect?For that matter, what sort of remedial action can a caller take if the return code is
-EEXIST? Is there any point in forcing callers to check the return code if they can't do anything about it?
See my reply to Geert from just now:
https://lore.kernel.org/r/[email protected]
I guess I can add another indirection to notifier_chain_register() and avoid touching all the call sites.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerQuoted 2 lines · Borislav Petkov
I guess I can add another indirection to
notifier_chain_register()and avoid touching all the call sites.
IOW, something like this below.
This way I won't have to touch all the callsites and the registration routines would still return a proper value instead of returning 0 unconditionally.
---
kernel/notifier.c +16 -6
@@ -19,14 +19,12 @@ BLOCKING_NOTIFIER_HEAD(reboot_notifier_list);* are layered on top of these, with appropriate locking added. */ -static int notifier_chain_register (struct notifier_block **nl, -struct notifier_block *n) +static int __notifier_chain_register (struct notifier_block **nl, +struct notifier_block *n) {while ((*nl) !=NULL ) { -if (unlikely ((*nl) == n)) { -WARN (1 ,"double register detected" ); -return 0 ; - } +if (unlikely ((*nl) == n)) +return -EEXIST ;if (n->priority > (*nl)->priority)break ; nl = &((*nl)->next);
@@ -36,6 +34,18 @@ static int notifier_chain_register(struct notifier_block **nl,return 0 ; } +static int notifier_chain_register (struct notifier_block **nl, +struct notifier_block *n) +{ +int ret =__notifier_chain_register (nl, n); + +if (ret == -EEXIST ) +WARN (1 ,"double register of notifier callback %ps detected" , + n->notifier_call); + +return ret; +} +static int notifier_chain_unregister (struct notifier_block **nl,struct notifier_block *n) {
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v0 35/42] sh: Check notifier registration return value
In reply to Borislav PetkovQuoted 19 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>--- arch/sh/kernel/cpu/sh4a/setup-sh7724.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/sh/kernel/cpu/sh4a/setup-sh7724.c +0
-0@@ -1277,11 +1277,14 @@ static struct notifier_block sh7724_post_sleep_notifier = {static int __init sh7724_sleep_setup (void )
arch/sh/kernel/cpu/sh4a/setup-sh7724.c static struct notifier_block sh7724_post_sleep_notifier = { · line 1286
Quoted 10 lines
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +7
-2{ -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" );
s/pre/post/? :-)
arch/sh/kernel/cpu/sh4a/setup-sh7724.c static struct notifier_block sh7724_post_sleep_notifier = { · line 1290
Quoted 6 lines
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +0
-2-atomic_notifier_chain_register (&sh_mobile_post_sleep_notifier_list, - &sh7724_post_sleep_notifier);return 0 ; }arch_initcall (sh7724_sleep_setup);
MBR, Sergey
Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered
In reply to Borislav PetkovHi Borislav,
Quoted 6 lines · Borislav Petkov
Quoted 2 lines · Geert Uytterhoeven
I think the addition of
__must_checkis overkill, leading to the addition of useless error checks and message printing.See the WARN in
notifier_chain_register()- it will already do "message printing".
I mean the addition of useless error checks and message printing _to the callers_.
Quoted 9 lines
Quoted 3 lines
Many callers call this where it cannot fail, and where nothing can be done in the very unlikely event that the call would ever start to fail.
This is an attempt to remove this
WARN()hack innotifier_chain_register()and have the function return a proper error value instead of this "Currently always returns zero." which is bad design.
Quoted 4 lines
Some of the registration functions around the tree check that retval and some don't. So if "it cannot fail" those registration either should not return a value or callers should check that return value - what we have now doesn't make a whole lot of sense.
With __must_check callers are required to check, even if they know it cannot fail.
Quoted 8 lines
Oh, and then fixing this should avoid stuff like:
(quoted diff) +4
-0+ if (notifier_registered == false) { + mce_register_decode_chain(&amdgpu_bad_page_nb); + notifier_registered = true; + }from propagating in the code.
That's unrelated to the addition of __must_check.
I'm not against returning proper errors codes. I'm against forcing callers to check things that cannot fail and to add individual error printing to each and every caller.
Note that in other areas, we are moving in the other direction, to a centralized printing of error messages, cfr. e.g. commit 7723f4c5ecdb8d83 ("driver core: platform: Add an error message to platform_get_irq*()").
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Borislav Petkov
maintainerRe: [PATCH v0 42/42] notifier: Return an error when callback is already registered
Quoted 3 lines · Geert Uytterhoeven
I'm not against returning proper errors codes. I'm against forcing callers to check things that cannot fail and to add individual error printing to each and every caller.
If you're against checking things at the callers, then the registration function should be void. IOW, those APIs are not optimally designed atm.
Quoted 4 lines
Note that in other areas, we are moving in the other direction, to a centralized printing of error messages, cfr. e.g. commit
7723f4c5ecdb8d83("driver core: platform: Add an error message to platform_get_irq*()").
Yes, thus my other idea to add a lower level __notifier_chain_register() to do the checking.
I'll see if I can convert those notifier registration functions to return void, in the process. But let's see what the others think first.
Thanks for taking the time.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v0 42/42] notifier: Return an error when callback is already registered
Hi Borislav,
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Geert Uytterhoeven
I'm not against returning proper errors codes. I'm against forcing callers to check things that cannot fail and to add individual error printing to each and every caller.
If you're against checking things at the callers, then the registration function should be void. IOW, those APIs are not optimally designed atm.
Returning void is the other extreme ;-)
There are 3 levels (ignoring BUG_ON()/panic () inside the callee):
1. Return void: no one can check success or failure,
2. Return an error code: up to the caller to decide,
3. Return a __must_check error code: every caller must check.
I'm in favor of 2, as there are several places where it cannot fail.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Borislav Petkov
maintainerRe: [PATCH v0 42/42] notifier: Return an error when callback is already registered
Quoted 8 lines · Geert Uytterhoeven
Returning void is the other extreme ;-)
There are 3 levels (ignoring BUG_ON()/panic () inside the callee):
1. Return void: no one can check success or failure,
2. Return an error code: up to the caller to decide,
3. Return a__must_checkerror code: every caller must check.I'm in favor of 2, as there are several places where it cannot fail.
Makes sense to me. I'll do that in the next iteration.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteSteven Rostedt
maintainerQuoted 9 lines · On Mon, 8 Nov 2021 15:35:50 +0100 Borislav Petkov <[email protected]> wrote:
Quoted 2 lines · Borislav Petkov
I guess I can add another indirection to
notifier_chain_register()and avoid touching all the call sites.IOW, something like this below.
This way I won't have to touch all the callsites and the registration routines would still return a proper value instead of returning 0 unconditionally.
I prefer this method.
Question, how often does this warning trigger? Is it common to see in development?
-- Steve
Borislav Petkov
maintainerQuoted 2 lines · Steven Rostedt
Question, how often does this warning trigger? Is it common to see in development?
Yeah, haven't seen it myself yet.
But we hashed it out over IRC. :-)
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v0 20/42] rcu: Check notifier registration return value
In reply to Borislav PetkovQuoted 7 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>
Or I would be happy to take this as soon as the first patch appears somewhere that I can base off of. (I could duplicate it in -rcu, I suppose.)
Thanx, Paul
Quoted 23 lines
--- kernel/rcu/tree_stall.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/rcu/tree_stall.h +3
-1@@ -101,7 +101,9 @@ static struct notifier_block rcu_panic_block = {static int __init check_cpu_stall_init (void ) { -atomic_notifier_chain_register (&panic_notifier_list, &rcu_panic_block); +if (atomic_notifier_chain_register (&panic_notifier_list, &rcu_panic_block)) +pr_warn ("RCU warning suppress notifier already registered\n" ); +return 0 ; }early_initcall (check_cpu_stall_init);Signature · 1 line
2.29.2
Re: [PATCH v0 37/42] sparc: Check notifier registration return value
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Date: Mon, 8 Nov 2021 11:11:52 +0100
Quoted 7 lines
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>
Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered
In reply to Borislav PetkovQuoted 11 lines · Borislav Petkov
Quoted 8 lines · Geert Uytterhoeven
Returning void is the other extreme ;-)
There are 3 levels (ignoring BUG_ON()/panic () inside the callee):
1. Return void: no one can check success or failure,
2. Return an error code: up to the caller to decide,
3. Return a__must_checkerror code: every caller must check.I'm in favor of 2, as there are several places where it cannot fail.
Makes sense to me. I'll do that in the next iteration.
Is there really any reason for returning an error code? For example, is it anticipated that at some point in the future these registration calls might fail?
Currently, the only reason for failing to register a notifier callback is because the callback is already registered. In a sense this isn't even an actual failure -- after the registration returns the callback _will_ still be registered.
So if the call can never really fail, why bother with a return code? Especially since the caller can't do anything with such a code value.
Given the current state of affairs, I vote in favor of 1 (plus a WARN or something similar to generate a stack dump in the callee, since double registration really is a bug).
Alan Stern
Borislav Petkov
maintainerRe: [PATCH v0 42/42] notifier: Return an error when callback is already registered
Quoted 5 lines · Alan Stern
Is there really any reason for returning an error code? For example, is it anticipated that at some point in the future these registration calls might fail?
Currently, the only reason for failing...
Right, I believe with not making it return void we're leaving the door open for some, *hypothetical* future return values if we decide we need to return them too, at some point.
Yes, I can't think of another fact to state besides that the callback was already registered or return success but who knows what we wanna do in the future...
And so if we change them all to void now, I think it'll be a lot more churn to switch back to returning a non-void value and having the callers who choose to handle that value, do so again.
So, long story short, keeping the retval - albeit not very useful right now - is probably easier.
I hope I'm making some sense here.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteCristian Marussi
reviewerRe: [PATCH v0 39/42] crypto: ccree - check notifier registration return value
In reply to Borislav PetkovQuoted 6 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Hi Borislav,
Quoted 11 lines
Signed-off-by Borislav Petkov <[email protected]>--- drivers/crypto/ccree/cc_fips.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/crypto/ccree/cc_fips.c +0
-0
drivers/crypto/ccree/cc_fips.c int cc_fips_init(struct cc_drvdata *p_drvdata) · line 152
Quoted 8 lines
drivers/crypto/ccree/cc_fips.c +3
-1@@ -146,7 +146,9 @@ int cc_fips_init(struct cc_drvdata *p_drvdata)tasklet_init (&fips_h->tasklet, fips_dsr, (unsigned long )p_drvdata); fips_h->drvdata = p_drvdata; fips_h->nb.notifier_call = cc_ree_fips_failure; -atomic_notifier_chain_register (&fips_fail_notif_chain, &fips_h->nb); + +if (atomic_notifier_chain_register (&fips_fail_notif_chain, &fips_h->nb)) +pr_warn ("Failure notifier already registered\n" );
Looking at the implementation of atomic_notifier_chain_register() and its internal helper down below, I can see that atomic_notifier_chain_register() ALWAYS return 0 (O_o) and anyway there is a WARN() in the notifiier core already to alert of double registrations.
What is the aim of this patch ?
It's not clear from the commit message what are you trying to achieve. Am I missing something ?
(Is it to circumvent some static checker to avoid this false positive ? just guessing...)
Thanks,
Cristian
-----8<----------
static int notifier_chain_register(struct notifier_block **nl,
struct notifier_block *n)
{
while ((*nl) != NULL) {
if (unlikely((*nl) == n)) {
WARN(1, "double register detected");
return 0;
}
if (n->priority > (*nl)->priority)
break;
nl = &((*nl)->next);
}
n->next = *nl;
rcu_assign_pointer(*nl, n);
return 0;
}/**
* atomic_notifier_chain_register - Add notifier to an atomic notifier chain * @nh: Pointer to head of the atomic notifier chain * @n: New entry in notifier chain
*
* Adds a notifier to an atomic notifier chain.
*
* Currently always returns zero.
*/
int atomic_notifier_chain_register(struct atomic_notifier_head *nh,
struct notifier_block *n)
{
unsigned long flags;
int ret;
spin_lock_irqsave(&nh->lock, flags);
ret = notifier_chain_register(&nh->head, n);
spin_unlock_irqrestore(&nh->lock, flags);
return ret;
}EXPORT_SYMBOL_GPL(atomic_notifier_chain_register);
------
Cristian Marussi
reviewerRe: [PATCH v0 06/42] firmware: Check notifier registration return value
In reply to Borislav PetkovQuoted 9 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Avoid homegrown notifier registration checks.
No functional changes.
Signed-off-by Borislav Petkov <[email protected]>---
Hi Borislav,
same observations I made on ccree patch in this series holds here too.
Moreover you should use get_maintainer.pl script to properly Cc people (reviewers/maintainers) beside mailing lists (I saw this by chance...):
as an additional note this patch also merges together two fixes for 2 completely different things (it should be split).
But, anyway, most of all, as said for ccree, I don't see the reason for these kind of fixes given the internals of notifier core.
Thanks,
Cristian
Quoted 43 lines
drivers/firmware/arm_scmi/notify.c | 3 ++- drivers/firmware/google/gsmi.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-)drivers/firmware/arm_scmi/notify.c +2
-1@@ -1358,7 +1358,8 @@ static int scmi_notifier_register(const struct scmi_handle *handle,if (!hndl)return -EINVAL ; -blocking_notifier_chain_register (&hndl->chain, nb); +if (blocking_notifier_chain_register (&hndl->chain, nb)) +pr_warn ("SCMI notifier already registered\n" );/* Enable events for not pending handlers */ if (!IS_HNDL_PENDING (hndl)) {drivers/firmware/google/gsmi.c +4
-2@@ -1030,8 +1030,10 @@ static __init int gsmi_init(void)register_reboot_notifier (&gsmi_reboot_notifier);register_die_notifier (&gsmi_die_notifier); -atomic_notifier_chain_register (&panic_notifier_list, - &gsmi_panic_notifier); + +if (atomic_notifier_chain_register (&panic_notifier_list, + &gsmi_panic_notifier)) +pr_warn ("gsmi panic notifier already registered\n" );printk (KERN_INFO "gsmi version " DRIVER_VERSION " loaded\n" );Signature · 7 lines
2.29.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Borislav Petkov
maintainerRe: [PATCH v0 39/42] crypto: ccree - check notifier registration return value
In reply to Cristian MarussiQuoted 4 lines · Cristian Marussi
Looking at the implementation of
atomic_notifier_chain_register()and its internal helper down below, I can see thatatomic_notifier_chain_register()ALWAYS return 0 (O_o) and anyway there is aWARN()in the notifiier core already to alert of double registrations.
You can ignore it - we agreed (at least no one has complained against it yet :)) on doing this instead:
https://lore.kernel.org/r/[email protected]
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette