Re: [PATCH v2] rust: opp: clone cpumask before adding OF table in from_of_cpumask()
From: Viresh Kumar
Date: Thu Dec 03 2026 - 05:09:43 EST
On 30-11-26, 21:17, Bilal Hashim wrote:
> In Table::from_of_cpumask(), CpumaskVar::try_clone(cpumask) is currently
> called after bindings::dev_pm_opp_of_cpumask_add_table() succeeds. If
> the cpumask allocation fails, Table is dropped before table.cpus is set,
> so Drop does not call dev_pm_opp_of_cpumask_remove_table() and the
> C-side cpumask OPP table is leaked.
>
> Clone the cpumask before calling dev_pm_opp_of_cpumask_add_table() so
> that an allocation failure returns cleanly without leaking the OPP
> table.
>
> Fixes: d52c7e868fbc ("rust: opp: Add abstractions for the OPP table")
> Signed-off-by: Bilal Hashim <AeeSec@xxxxxxx>
> ---
> Changes in v2:
> - Drop the unreachable Self::from_dev() error rollback hunks in
> Table::from_of() and Table::from_of_cpumask() and keep only the
> CpumaskVar::try_clone() move (thanks to Zhongqiu Han).
> - Update commit message and add Fixes: tag.
> ---
> rust/kernel/opp.rs | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Applied. Thanks.
--
viresh