On Tue Jun 16, 2026 at 3:38 PM BST, Philipp Stanner wrote: > On Tue, 2026-06-16 at 15:47 +0300, Onur Özkan wrote: >> On Tue, 16 Jun 2026 10:28:17 +0200 >> > + >> > + // DriverFenceData is repr(C) and a Fence is its first member. >> > + let fence_data_ptr = fence_ptr as *mut DriverFenceData<T>; >> >> Either the field ordering on the type or this code is wrong because the first >> member of DriverFenceData is `rcu_head`. > > Yeah, that's a bug introduced in this revision. Thx for pointing it > out. Already fixed it downstream. > > I'm just wondering why my test did not blow up. > >> > >> > +} >> >> I am unsure whether it is safe to cast the pointer in Fence::from_raw without >> Fence being #[repr(transparent)] as the layout compatibility is not >> guaranteed >> explicitly. > > Shouldn't #[repr(C)] do that trick, too? Do you need both? > > Who can answer that?
You have `#[repr(C)]` for DriverFence, but not on `Fence`. `Fence::from_raw` does require layout equivalence between `Fence` and `bindings::dma_fence` and this is done by adding `#[repr(transparent)]` on `Fence`. Best, Gary

