Re: [PATCH v3] rust: regulator: add a bare minimum regulator abstraction
From: Mark Brown
Date: Mon May 19 2025 - 08:47:15 EST
On Mon, May 19, 2025 at 02:30:05PM +0200, Benno Lossin wrote:
> On Mon May 19, 2025 at 1:46 PM CEST, Mark Brown wrote:
> > If you don't disable the regulator you've just leaked a reference which
> > is obviously a problem.
> For sure. But I'm trying to figure out if this is a safety-related issue
> or not. Safety in Rust has a rather specific meaning that can be
> summarized with "no UB". So since the C side does nothing if the user
> screwed up the refcounts, it lets me to believe that we don't have any
> safety related issues when forgetting to call `regulator_disable`.
> Of course we still should strive for an API that makes that impossible
> or at least very hard, but we don't need to make the API `unsafe` or
> have to take special care. (At least if I understood correctly)
Yes, it's relatively unlikely that it would lead to any undefined
behaviour. There is an API for crashing through the refcounts and
disabling if we detect some emergency, but that's very extreme.
Attachment:
signature.asc
Description: PGP signature