mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
clk: Sanitize possible_parent_show to Handle Return Value of of_clk_get_parent_name
commitceb87a361dupstream. In the possible_parent_show function, ensure proper handling of the return value from of_clk_get_parent_name to prevent potential issues arising from a NULL return. The current implementation invokes seq_puts directly on the result of of_clk_get_parent_name without verifying the return value, which can lead to kernel panic if the function returns NULL. This patch addresses the concern by introducing a check on the return value of of_clk_get_parent_name. If the return value is not NULL, the function proceeds to call seq_puts, providing the returned value as argument. However, if of_clk_get_parent_name returns NULL, the function provides a static string as argument, avoiding the panic. Fixes:1ccc0ddf04("clk: Use seq_puts() in possible_parent_show()") Reported-by: Philip Daly <pdaly@redhat.com> Signed-off-by: Alessandro Carminati (Red Hat) <alessandro.carminati@gmail.com> Link: https://lore.kernel.org/r/20230921073217.572151-1-alessandro.carminati@gmail.com Signed-off-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
65e5a9890e
commit
48ebeab0ed
@@ -3340,6 +3340,7 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
|
|||||||
unsigned int i, char terminator)
|
unsigned int i, char terminator)
|
||||||
{
|
{
|
||||||
struct clk_core *parent;
|
struct clk_core *parent;
|
||||||
|
const char *name = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go through the following options to fetch a parent's name.
|
* Go through the following options to fetch a parent's name.
|
||||||
@@ -3354,18 +3355,20 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
|
|||||||
* registered (yet).
|
* registered (yet).
|
||||||
*/
|
*/
|
||||||
parent = clk_core_get_parent_by_index(core, i);
|
parent = clk_core_get_parent_by_index(core, i);
|
||||||
if (parent)
|
if (parent) {
|
||||||
seq_puts(s, parent->name);
|
seq_puts(s, parent->name);
|
||||||
else if (core->parents[i].name)
|
} else if (core->parents[i].name) {
|
||||||
seq_puts(s, core->parents[i].name);
|
seq_puts(s, core->parents[i].name);
|
||||||
else if (core->parents[i].fw_name)
|
} else if (core->parents[i].fw_name) {
|
||||||
seq_printf(s, "<%s>(fw)", core->parents[i].fw_name);
|
seq_printf(s, "<%s>(fw)", core->parents[i].fw_name);
|
||||||
else if (core->parents[i].index >= 0)
|
} else {
|
||||||
seq_puts(s,
|
if (core->parents[i].index >= 0)
|
||||||
of_clk_get_parent_name(core->of_node,
|
name = of_clk_get_parent_name(core->of_node, core->parents[i].index);
|
||||||
core->parents[i].index));
|
if (!name)
|
||||||
else
|
name = "(missing)";
|
||||||
seq_puts(s, "(missing)");
|
|
||||||
|
seq_puts(s, name);
|
||||||
|
}
|
||||||
|
|
||||||
seq_putc(s, terminator);
|
seq_putc(s, terminator);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user