Re: [PATCH treewide 4/5] iio: frequency: adf4377: Make sure clk_init_data is fully initialized

[email protected]
Newsgroups org.infradead.lists.linux-amlogic,org.kernel.vger.linux-clk,org.kernel.vger.linux-hwmon
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Incomplete fix for uninitialized stack variables: `struct clk_parent_data parent_data` remains uninitialized on the stack, leading to a kernel crash during clock registration.
--

--- Patch [4]: [PATCH treewide 4/5] iio: frequency: adf4377: Make sure clk_init_data is fully initialized ---
commit 99e024a77f5bce5921d3c6b46054263aa450610d
Author: Geert Uytterhoeven <[email protected]>

iio: frequency: adf4377: Make sure clk_init_data is fully initialized

This commit initializes the clk_init_data structure in
adf4377_clk_register() to zero. This prevents crashes caused by
uninitialized fields like parent_names when CONFIG_INIT_STACK_ALL_PATTERN
or CONFIG_INIT_STACK_NONE is enabled.

> diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c
> --- a/drivers/iio/frequency/adf4377.c
> +++ b/drivers/iio/frequency/adf4377.c
> @@ -999,7 +999,7 @@ static int adf4377_clk_register(struct adf4377_state *st)
>  {
>  	struct spi_device *spi = st->spi;
>  	struct device *dev = &spi->dev;
> -	struct clk_init_data init;
> +	struct clk_init_data init = {};
>  	struct clk_parent_data parent_data;

[Severity: High]
This is a pre-existing issue, but does this struct clk_parent_data also
need to be zero-initialized?

Only fw_name is explicitly assigned below, leaving name, hw, and index
populated with stack garbage. When adf4377_clk_register() passes this to
the clock framework, clk_core_populate_parent_map() will read
parent_data.name and pass it to clk_cpy_name(), which ultimately calls
strlen() and can cause a page fault during probe.

[ ... ]

>  	parent_data.fw_name = "ref_in";
>  
>  	init.ops = &adf4377_clk_ops;
>  	init.parent_data = &parent_data;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.