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 CC9CF3909B7; Tue, 19 May 2026 06:26:17 +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=1779171977; cv=none; b=a0H283EFgc4p5lVv7NWs4TkL2ynEF3gHV+mo+7u2cJTgjPl5wmtla/ZC89ZGEli7bRXv7q8VR+Jy4T1R57dlj9/JU0c+tB6AUh0bdNWP72T9gE8bGODYObtnawgQPrFMLqDQ0FMoEK9KaLZEkzKeEjDPGmeArwcYMwNmn0MvEIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779171977; c=relaxed/simple; bh=OYexPkFtbNXLRo2lAEdq2hETmjni7pCbYaSDRmMBwas=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l1ra3tpKIFGv1rKCrRQKtdvEJ9uEJQ90ZD7OmBnmSwb7VBX8yi/yspEXjin5PzhFoFrkNi40kNtFFngRRDlB8eOPwLH9YtxG+rgLK8LJOfesW19fdHkI9ExLhbGQTOCBsdbXMWAcKXj9B8mlq23CE6xKL8WC9HjW/LZQ5J1GHBE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=jYq1BxJE; 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="jYq1BxJE" Received: by smtp.kernel.org (Postfix) with ESMTPS id 58486C32782; Tue, 19 May 2026 06:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1779171977; bh=OYexPkFtbNXLRo2lAEdq2hETmjni7pCbYaSDRmMBwas=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jYq1BxJEdQvoKO+B5LkE3eiPcpa0MF5xhNY1fdxCle42kKHyxfk7R4sczzyTGNma2 r4joKWNmfvhvmSicZVj57PJe4ycBlSGeSiZGYm8DN7PZxe9bZlJwn9mElB733ut/Tl AYhjZS49JTvqhFkdRHEZ0tzUpVJQKk+dPEuxyGy0= 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 4B5BDCD4F54; Tue, 19 May 2026 06:26:17 +0000 (UTC) From: Alvin Sun Date: Tue, 19 May 2026 14:26:18 +0800 Subject: [PATCH 6/8] 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: <20260519-fix-fops-owner-v1-6-2ded9830da14@linux.dev> References: <20260519-fix-fops-owner-v1-0-2ded9830da14@linux.dev> In-Reply-To: <20260519-fix-fops-owner-v1-0-2ded9830da14@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 Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, driver-core@lists.linux.dev, dri-devel@lists.freedesktop.org, nova-gpu@lists.linux.dev, Alvin Sun X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1779171975; l=1749; i=alvin.sun@linux.dev; s=20260317; h=from:subject:message-id; bh=OYexPkFtbNXLRo2lAEdq2hETmjni7pCbYaSDRmMBwas=; b=ZyFmcBxw1iqk+SIxcFeBTJnMObx+OCnY/wJV2uLHPgpVqGkQc8wSk9AV2oIMUMbAUJCcFOIHy y/WAWqV40x1DC2MLK8BHskY3T8WYx1cAY5qNGMhhCRZZXMt4iSuiHzp 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. 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..97bee53823346 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(::MODULE_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