[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQTLHlv2_V9Pgjk3@smile.fi.intel.com>
Date: Fri, 31 Oct 2025 16:43:42 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Markus Elfring <Markus.Elfring@....de>
Cc: linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
Michael Turquette <mturquette@...libre.com>,
Nishanth Menon <nm@...com>, Raag Jadav <raag.jadav@...el.com>,
Santosh Shilimkar <ssantosh@...nel.org>,
Stephen Boyd <sboyd@...nel.org>, Tero Kristo <kristo@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] clk: keystone: sci-clk: use devm_kmemdup_array() once
more in ti_sci_scan_clocks_from_fw()
On Fri, Oct 31, 2025 at 03:33:24PM +0100, Markus Elfring wrote:
>
> * Reuse existing functionality from devm_kmemdup_array()
> instead of keeping duplicate source code.
>
> * Prevent a null pointer dereference.
>
>
> The source code was transformed by using the Coccinelle software.
>
> Fixes: 3c13933c60338ce6fb2369bd0e93f91e52ddc17d ("clk: keystone: sci-clk: add support for dynamically probing clocks")
Wrong format of Fixes tag, please keep the SHA at bare minumum.
...
> if (num_clks == max_clks) {
> - tmp_clks = devm_kmalloc_array(dev, max_clks + 64,
> - sizeof(sci_clk),
> - GFP_KERNEL);
> - memcpy(tmp_clks, clks, max_clks * sizeof(sci_clk));
> + tmp_clks = devm_kmemdup_array(dev, clks, max_clks + 64,
> + sizeof(sci_clk), GFP_KERNEL);
> if (max_clks)
> devm_kfree(dev, clks);
> + if (!tmp_clks)
> + return -ENOMEM;
You haven't read the code, right?
This now will work differently. Would it be acceptable?
> max_clks += 64;
> clks = tmp_clks;
> }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists