Re: [PATCH v3 6/8] pwm: rzg2l-gpt: Add suspend/resume support

From: Uwe Kleine-König

Date: Mon Dec 01 2025 - 10:29:11 EST


Hello Biju,

On Mon, Dec 01, 2025 at 03:04:08PM +0000, Biju Das wrote:
> You mean to avoid unbalance between suspend()/resume(), we should not
> do error handling in resume()??

Consider the following resume function:

static int myresume(...)
{
ret = enable_some_resource(...);
if (ret)
return ret;

ret = enable_some_other_resource(...)
if (ret) {
disable_some_resource();
return ret;

}

return 0;
}

If disable_some_resource() can fail it might happen that the first call
to myresume() is left with some_resource enabled and some_other_resource
disabled (i.e. if both enable_some_other_resource() and
disable_some_resource() fail). Now if the resume is retried
some_resource is enabled a second time without being tracked and a later
suspend (or remove) won't bring the enable count to 0 and thus leak a
resource.

Best regards
Uwe

Attachment: signature.asc
Description: PGP signature