[PATCH RFC] clk: keystone: sci-clk: check the growing discovery array

Slavin Liu posted 1 patch 2 weeks ago
drivers/clk/keystone/sci-clk.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH RFC] clk: keystone: sci-clk: check the growing discovery array
Posted by Slavin Liu 2 weeks ago
Check each newly allocated discovery array before copying existing
entries or publishing its first element. Devres releases prior storage
when the probe fails.

Detected by static analysis and reviewed with AI-assisted source auditing.

Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")
Assisted-by: LLM
Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
---
 drivers/clk/keystone/sci-clk.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
index 9d2094bd48e3..dad2fb67c405 100644
--- a/drivers/clk/keystone/sci-clk.c
+++ b/drivers/clk/keystone/sci-clk.c
@@ -496,6 +496,8 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider)
 			tmp_clks = devm_kmalloc_array(dev, max_clks + 64,
 						      sizeof(sci_clk),
 						      GFP_KERNEL);
+			if (!tmp_clks)
+				return -ENOMEM;
 			memcpy(tmp_clks, clks, max_clks * sizeof(sci_clk));
 			if (max_clks)
 				devm_kfree(dev, clks);
Re: [PATCH RFC] clk: keystone: sci-clk: check the growing discovery array
Posted by Nishanth Menon 1 week, 6 days ago
On 14:09-20260911, Slavin Liu wrote:
> Check each newly allocated discovery array before copying existing
> entries or publishing its first element. Devres releases prior storage
> when the probe fails.
> 
> Detected by static analysis and reviewed with AI-assisted source auditing.

Why RFC?

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
https://ti.com/opensource