From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 598BF394463; Sat, 27 Jun 2026 09:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782552528; cv=none; b=DiZz8nhwOS4kq7YACxlAhIX8mNlWogse0WXTgGaFoO/OpH303KVubJQJsYirqUzTmzicuIGjZoK2d39mpYrxC98i3J8kc74fX6pvNMvR2sAiso7p+2xlxTtaH1sAPJIbByGrc9e95x6zN0WOyqc498bANm7uUI9FTKQ9N1xcLM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782552528; c=relaxed/simple; bh=et7aLWDdt16IGyYP6zeuD/W5wjktc0zJWIypSVqeW1w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T5SEnCXUDqzK4GMvlB0FC7m22uegTmqqzVzETKJkcrrbVJjYVq/CNGRQyga4RWXGG7tD3CFJ9ldKMWYG9JgDOIBtWn2walvjR7WSwHmlIVToYO26NTgEIuE8uq6oBm/czUYSKJsTU8XXlYcHN2pr+2bkIHnYwJZyw9XZ3s2dFXI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tfpEKLSm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tfpEKLSm" Received: by smtp.kernel.org (Postfix) with ESMTPS id 17B3DC2BD00; Sat, 27 Jun 2026 09:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1782552528; bh=et7aLWDdt16IGyYP6zeuD/W5wjktc0zJWIypSVqeW1w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tfpEKLSmvyN9A1wXerCCO4fLxnvVbmMgQdzlqx/42SCeA/Jn9WeIixUdQx2/r2Cfi C88LzgPQuTnyW514eL0RS/2m1K2YbMPKuxe3syFoRPxjmeCR/61ddI6do+HO/4ZdKG J4WZoJD0ajV4/KsOJkm2Rv7wJrKDxomJ1X3U7v4A= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 098F2C43327; Sat, 27 Jun 2026 09:28:48 +0000 (UTC) From: Alvin Sun Date: Sat, 27 Jun 2026 17:28:43 +0800 Subject: [PATCH v7 05/10] rust: drm: set fops.owner from driver module pointer Precedence: bulk X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260627-fix-fops-owner-v7-5-33cd3990edf0@linux.dev> References: <20260627-fix-fops-owner-v7-0-33cd3990edf0@linux.dev> In-Reply-To: <20260627-fix-fops-owner-v7-0-33cd3990edf0@linux.dev> To: Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Greg Kroah-Hartman , "Rafael J. Wysocki" , David Airlie , Simona Vetter , Daniel Almeida , Arnd Bergmann , Brendan Higgins , David Gow , Rae Moar , Breno Leitao , Jens Axboe , Dave Ertman , Leon Romanovsky , Igor Korotin , FUJITA Tomonori , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas Cc: rust-for-linux@vger.kernel.org, linux-modules@vger.kernel.org, driver-core@lists.linux.dev, dri-devel@lists.freedesktop.org, nova-gpu@lists.linux.dev, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, Alvin Sun X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1782552525; l=1926; i=alvin.sun@linux.dev; s=20260317; h=from:subject:message-id; bh=et7aLWDdt16IGyYP6zeuD/W5wjktc0zJWIypSVqeW1w=; b=LX7kLrB82mAeT+ffMcLf4/CvcAX40EqOdjzC+o+ObrDwNfuytN1KxXt4/dlXRYs1w18PDs8Lv lwfyCjJConRDgXtY/M/N33jP4uEBgyN3/LXZd3JHSPTi2ufqfIIDTXM X-Developer-Key: i=alvin.sun@linux.dev; a=ed25519; pk=CHcwQp8GSoj25V/L1ZWNSQjWp9eSIb0s9LKr0Nm3WuE= X-Endpoint-Received: by B4 Relay for alvin.sun@linux.dev/20260317 with auth_id=684 Change `create_fops()` to accept an owner module pointer instead of hardcoding `null_mut()`, ensuring the kernel correctly tracks the module owning the DRM device's file operations. Assisted-by: opencode:glm-5.2 Reviewed-by: Andreas Hindborg Reviewed-by: Gary Guo Acked-by: Danilo Krummrich Signed-off-by: Alvin Sun --- rust/kernel/drm/device.rs | 3 ++- rust/kernel/drm/gem/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs index 403fc35353c74..d92cacb665366 100644 --- a/rust/kernel/drm/device.rs +++ b/rust/kernel/drm/device.rs @@ -111,7 +111,8 @@ impl Device { fops: &Self::GEM_FOPS, }; - const GEM_FOPS: bindings::file_operations = drm::gem::create_fops(); + const GEM_FOPS: bindings::file_operations = + drm::gem::create_fops(crate::module::this_module::().as_ptr()); /// Create a new `drm::Device` for a `drm::Driver`. pub fn new(dev: &device::Device, data: impl PinInit) -> Result> { diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index 01b5bd47a3332..9a203efc59116 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -357,10 +357,10 @@ impl AllocImpl for Object { }; } -pub(super) const fn create_fops() -> bindings::file_operations { +pub(super) const fn create_fops(owner: *mut bindings::module) -> bindings::file_operations { let mut fops: bindings::file_operations = pin_init::zeroed(); - fops.owner = core::ptr::null_mut(); + fops.owner = owner; fops.open = Some(bindings::drm_open); fops.release = Some(bindings::drm_release); fops.unlocked_ioctl = Some(bindings::drm_ioctl); -- 2.43.0