From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: devres: return reference in `devres::register` Date: Tue, 05 May 2026 11:18:29 +1000 Message-ID: In-Reply-To: <20260429-rust_serdev-v7-1-0d89c791b5c8@posteo.de> References: <20260429-rust_serdev-v7-0-0d89c791b5c8@posteo.de> <20260429-rust_serdev-v7-1-0d89c791b5c8@posteo.de> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review **Summary:** Changes `devres::register` from returning `Result` to `Result<&'a T>`, tying the returned reference's lifetime to the `&'a Device` parameter. The safety argument is sound: devres-managed data is freed when the device is unbound, and holding a `&'a Device` guarantees the device hasn't been unbound for lifetime `'a`. The pointer is captured before `register_foreign` takes ownership of the `KBox`: ```rust + let data_ptr = &raw const *data; + register_foreign(dev, data) + // SAFETY: `dev` is valid for the lifetime of 'a. As long as there is a reference to + // `Device`, it is guaranteed that the device is not unbound and data has not been + // dropped. Thus `data_ptr` is also valid for the lifetime of 'a. + .map(|()| unsafe { &*data_ptr }) ``` The callers in `cpufreq.rs` and `drm/driver.rs` are updated to discard the new return value with `?; Ok(())`, which is correct. This patch is clean. No issues. --- --- Generated by Claude Code Patch Reviewer