Re: [PATCH v3] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

From: Johan Hovold
Date: Tue Apr 27 2021 - 11:05:22 EST


On Tue, Apr 27, 2021 at 02:58:34PM +0200, Julia Lawall wrote:
> pm_runtime_get_sync keeps a reference count on failure, which can lead
> to leaks. pm_runtime_resume_and_get drops the reference count in the
> failure case. This rule very conservatively follows the definition of
> pm_runtime_resume_and_get to address the cases where the reference
> count is unlikely to be needed in the failure case. Specifically, the
> change is only done when pm_runtime_get_sync is followed immediately
> by an if and when the branch of the if is immediately a call to
> pm_runtime_put_noidle (like in the definition of
> pm_runtime_resume_and_get) or something that is likely a print
> statement followed by a pm_runtime_resume_and_get call. The patch

s/pm_runtime_resume_and_get/pm_runtime_put_noidle/

> case appears somewhat more complicated, because it also deals with the
> cases where {}s need to be removed.
>
> pm_runtime_resume_and_get was introduced in
> commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to
> deal with usage counter")
>
> Signed-off-by: Julia Lawall <Julia.Lawall@xxxxxxxx>
>
> ---
> v3: add the people who signed off on commit dd8088d5a896, expand the log message
> v2: better keyword

Johan