lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aCRKR5h_X04OXgjq@finisterre.sirena.org.uk>
Date: Wed, 14 May 2025 09:46:15 +0200
From: Mark Brown <broonie@...nel.org>
To: Benno Lossin <lossin@...nel.org>
Cc: Daniel Almeida <daniel.almeida@...labora.com>,
	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
	Danilo Krummrich <dakr@...nel.org>,
	Boris Brezillon <boris.brezillon@...labora.com>,
	Sebastian Reichel <sebastian.reichel@...labora.com>,
	Liam Girdwood <lgirdwood@...il.com>, linux-kernel@...r.kernel.org,
	rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v3] rust: regulator: add a bare minimum regulator
 abstraction

On Tue, May 13, 2025 at 10:01:05PM +0200, Benno Lossin wrote:
> On Tue May 13, 2025 at 5:44 PM CEST, Daniel Almeida wrote:

> > +/// A [`Regulator`] that is known to be enabled.
> > +///
> > +/// # Invariants
> > +///
> > +/// - [`EnabledRegulator`] is a valid regulator that has been enabled.

> This isn't fully clear what it's supposed to mean to me. Maybe mention
> the `regulator_enable` function?

I suspect this is adequately clear to someone with the domain specific
knowledge required to be using the API.

> > +impl EnabledRegulator {
> > +    fn as_ptr(&self) -> *mut bindings::regulator {
> > +        self.inner.inner.as_ptr()
> > +    }

> > +    /// Disables the regulator.
> > +    pub fn disable(self) -> Result<Regulator> {
> > +        // Keep the count on `regulator_get()`.
> > +        let regulator = ManuallyDrop::new(self);

> Why don't we drop the refcount if the `regulator_disable` call fails?

If you fail to disable the regulator then the underlying C code won't
drop it's reference count.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ