]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
rust: alloc: fix `rusttest` by providing `Cmalloc::aligned_layout` too
authorMiguel Ojeda <ojeda@kernel.org>
Sat, 16 Aug 2025 20:42:15 +0000 (22:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:31:13 +0000 (16:31 +0200)
commita0d2e6f9d34a6753e6cea3e3ca245a59944c77f3
treef9cbc659b0fc86fd706581c155175c9325cdd8b2
parentbce19c62ed007579a6663a1c6535e25123605dc3
rust: alloc: fix `rusttest` by providing `Cmalloc::aligned_layout` too

[ Upstream commit 0f580d5d3d9d9cd0953695cd32e43aac3a946338 ]

Commit fde578c86281 ("rust: alloc: replace aligned_size() with
Kmalloc::aligned_layout()") provides a public `aligned_layout` function
in `Kamlloc`, but not in `Cmalloc`, and thus uses of it will trigger an
error in `rusttest`.

Such a user appeared in the following commit 22ab0641b939 ("rust: drm:
ensure kmalloc() compatible Layout"):

    error[E0599]: no function or associated item named `aligned_layout` found for struct `alloc::allocator_test::Cmalloc` in the current scope
       --> rust/kernel/drm/device.rs:100:31
        |
    100 |         let layout = Kmalloc::aligned_layout(Layout::new::<Self>());
        |                               ^^^^^^^^^^^^^^ function or associated item not found in `Cmalloc`
        |
       ::: rust/kernel/alloc/allocator_test.rs:19:1
        |
    19  | pub struct Cmalloc;
        | ------------------ function or associated item `aligned_layout` not found for this struct

Thus add an equivalent one for `Cmalloc`.

Fixes: fde578c86281 ("rust: alloc: replace aligned_size() with Kmalloc::aligned_layout()")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/r/20250816204215.2719559-1-ojeda@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
rust/kernel/alloc/allocator_test.rs