Re: [PATCH] rust: drm: ioctl: fix call to unsafe function
From: Gary Guo
Date: Wed Nov 18 2026 - 12:46:13 EST
On Wed Nov 18, 2026 at 4:57 PM GMT, Vishal Moola (Fractile) wrote:
> On Wed, Nov 18, 2026 at 05:17:41PM +0100, Danilo Krummrich wrote:
>> On Wed Nov 18, 2026 at 2:32 PM CET, Vishal Moola (Fractile) wrote:
>> > diff --git a/rust/kernel/drm/ioctl.rs b/rust/kernel/drm/ioctl.rs
>> > index 64af9eacc306..5a2e2f4f0e91 100644
>> > --- a/rust/kernel/drm/ioctl.rs
>> > +++ b/rust/kernel/drm/ioctl.rs
>> > @@ -152,7 +152,7 @@ macro_rules! declare_drm_ioctls {
>> > // dev/file match the current driver these ioctls are being declared
>> > // for, and it's not clear how to enforce this within the type system.
>> > let dev: &$crate::drm::device::Device<_, $crate::drm::Ioctl> =
>> > - $crate::drm::device::Device::from_raw(raw_dev);
>> > + unsafe { $crate::drm::device::Device::from_raw(raw_dev) };
>>
>> I remember there has been at least one compiler version in the supported range
>> that complained when the safety comment isn't directly above the unsafe block.
>> Has this been fixed in the meantime?
>
> I'm not sure? I'm compiling with rustc 1.98.1 (48a229cea 2026-09-01) (Fedora 1.98.1-1.fc44)
> which gives me no errors like this.
>
> Hopefully the build-bots catch it if there's a specific compiler version
> that still dislikes it.
>
> The following command shows a few other occurences in the kernel like this,
> so if its still an issue I imagine it'd likely be caught somewhere:
>
> grep -rn -B1 '^\s*unsafe {' rust/kernel | grep '=$'
In this particular case, Clippy 1.85 doesn't complain even if SAFETY comment is
removed, so we are all good.
Old version of clippy (the minimum version we require is 1.85) have both false
positive and false negatives and sometimes things just cancel out :)
Best,
Gary