Re: [Openipmi-developer] [PATCH] ipmi:ipmb: Fix refcount leak in ipmi_ipmb_probe

2022-05-12 Thread Corey Minyard
On Thu, May 12, 2022 at 08:44:45AM +0400, Miaoqian Lin wrote:
> of_parse_phandle() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when done.
> Add missing of_node_put() to avoid refcount leak.

Thanks, applied and backport requested for 5.17.

-corey

> 
> Fixes: 00d93611f002 ("ipmi:ipmb: Add the ability to have a separate slave and 
> master device")
> Signed-off-by: Miaoqian Lin 
> ---
>  drivers/char/ipmi/ipmi_ipmb.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/char/ipmi/ipmi_ipmb.c b/drivers/char/ipmi/ipmi_ipmb.c
> index b81b862532fb..a8bfe0ade082 100644
> --- a/drivers/char/ipmi/ipmi_ipmb.c
> +++ b/drivers/char/ipmi/ipmi_ipmb.c
> @@ -476,6 +476,7 @@ static int ipmi_ipmb_probe(struct i2c_client *client,
>   slave_np = of_parse_phandle(dev->of_node, "slave-dev", 0);
>   if (slave_np) {
>   slave_adap = of_get_i2c_adapter_by_node(slave_np);
> + of_node_put(slave_np);
>   if (!slave_adap) {
>   dev_notice(>dev,
>  "Could not find slave adapter\n");
> -- 
> 2.25.1
> 


___
Openipmi-developer mailing list
Openipmi-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openipmi-developer


Re: [Openipmi-developer] [PATCH 24/30] panic: Refactor the panic path

2022-05-12 Thread Petr Mladek via Openipmi-developer
Hello,

first, I am sorry for stepping into the discussion so late.
I was busy with some other stuff and this patchset is far
from trivial.

Second, thanks a lot for putting so much effort into it.
Most of the changes look pretty good, especially all
the fixes of particular notifiers and split into
four lists.

Though this patch will need some more love. See below
for more details.


On Wed 2022-04-27 19:49:18, Guilherme G. Piccoli wrote:
> The panic() function is somewhat convoluted - a lot of changes were
> made over the years, adding comments that might be misleading/outdated
> now, it has a code structure that is a bit complex to follow, with
> lots of conditionals, for example. The panic notifier list is something
> else - a single list, with multiple callbacks of different purposes,
> that run in a non-deterministic order and may affect hardly kdump
> reliability - see the "crash_kexec_post_notifiers" workaround-ish flag.
> 
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -3784,6 +3791,33 @@
>   timeout < 0: reboot immediately
>   Format: 
>  
> + panic_notifiers_level=
> + [KNL] Set the panic notifiers execution order.
> + Format: 
> + We currently have 4 lists of panic notifiers; based
> + on the functionality and risk (for panic success) the
> + callbacks are added in a given list. The lists are:
> + - hypervisor/FW notification list (low risk);
> + - informational list (low/medium risk);
> + - pre_reboot list (higher risk);
> + - post_reboot list (only run late in panic and after
> + kdump, not configurable for now).
> + This parameter defines the ordering of the first 3
> + lists with regards to kdump; the levels determine
> + which set of notifiers execute before kdump. The
> + accepted levels are:

This talks only about kdump. The reality is much more complicated.
The level affect the order of:

+ notifiers vs. kdump
+ notifiers vs. crash_dump
+ crash_dump vs. kdump

There might theoretically many variants of the ordering of kdump,
crash_dump, and the 4 notifier list. Some variants do not make
much sense. You choose 5 variants and tried to select them by
a level number.

The question is if we really could easily describe the meaning this
way. It is not only about a "level" of notifiers before kdump. It is
also about the ordering of crash_dump vs. kdump. IMHO, "level"
semantic does not fit there.

Maybe more parameters might be easier to understand the effect.
Anyway, we first need to agree on the chosen variants.
I am going to discuss it more in the code, see below.



> + 0: kdump is the first thing to run, NO list is
> + executed before kdump.
> + 1: only the hypervisor list is executed before kdump.
> + 2 (default level): the hypervisor list and (*if*
> + there's any kmsg_dumper defined) the informational
> + list are executed before kdump.
> + 3: both the hypervisor and the informational lists
> + (always) execute before kdump.
> + 4: the 3 lists (hypervisor, info and pre_reboot)
> + execute before kdump - this behavior is analog to the
> + deprecated parameter "crash_kexec_post_notifiers".
> +
>   panic_print=Bitmask for printing system info when panic happens.
>   User can chose combination of the following bits:
>   bit 0: print all tasks info
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -183,6 +195,112 @@ static void panic_print_sys_info(bool console_flush)
>   ftrace_dump(DUMP_ALL);
>  }
>  
> +/*
> + * Helper that accumulates all console flushing routines executed on panic.
> + */
> +static void console_flushing(void)
> +{
> +#ifdef CONFIG_VT
> + unblank_screen();
> +#endif
> + console_unblank();
> +
> + /*
> +  * In this point, we may have disabled other CPUs, hence stopping the
> +  * CPU holding the lock while still having some valuable data in the
> +  * console buffer.
> +  *
> +  * Try to acquire the lock then release it regardless of the result.
> +  * The release will also print the buffers out. Locks debug should
> +  * be disabled to avoid reporting bad unlock balance when panic()
> +  * is not being called from OOPS.
> +  */
> + debug_locks_off();
> + console_flush_on_panic(CONSOLE_FLUSH_PENDING);
> +
> + panic_print_sys_info(true);
> +}
> +
> +#define PN_HYPERVISOR_BIT0
> +#define PN_INFO_BIT  1
> +#define 

[Openipmi-developer] [PATCH] ipmi:ipmb: Fix refcount leak in ipmi_ipmb_probe

2022-05-12 Thread Miaoqian Lin
of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when done.
Add missing of_node_put() to avoid refcount leak.

Fixes: 00d93611f002 ("ipmi:ipmb: Add the ability to have a separate slave and 
master device")
Signed-off-by: Miaoqian Lin 
---
 drivers/char/ipmi/ipmi_ipmb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/ipmi/ipmi_ipmb.c b/drivers/char/ipmi/ipmi_ipmb.c
index b81b862532fb..a8bfe0ade082 100644
--- a/drivers/char/ipmi/ipmi_ipmb.c
+++ b/drivers/char/ipmi/ipmi_ipmb.c
@@ -476,6 +476,7 @@ static int ipmi_ipmb_probe(struct i2c_client *client,
slave_np = of_parse_phandle(dev->of_node, "slave-dev", 0);
if (slave_np) {
slave_adap = of_get_i2c_adapter_by_node(slave_np);
+   of_node_put(slave_np);
if (!slave_adap) {
dev_notice(>dev,
   "Could not find slave adapter\n");
-- 
2.25.1



___
Openipmi-developer mailing list
Openipmi-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openipmi-developer