Re: [PATCH] PM: runtime: Annotate pm_runtime_resume_and_get() as __must_check
From: "Rafael J. Wysocki" <rafael@kernel.org>
Date: 2021-12-30 15:34:34
On Thu, Dec 23, 2021 at 8:21 AM Heiner Kallweit [off-list ref] wrote:
quoted hunk ↗ jump to hunk
In the error case this function returns w/o the usage counter being incremented. Not checking the return code will likely result in a usage counter imbalance in the error case therefore. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> --- include/linux/pm_runtime.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index eddd66d42..aa106f5fb 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h@@ -384,9 +384,8 @@ static inline int pm_runtime_get(struct device *dev) * The possible return values of this function are the same as for * pm_runtime_resume() and the runtime PM usage counter of @dev remains * incremented in all cases, even if it returns an error code. - * Consider using pm_runtime_resume_and_get() instead of it, especially - * if its return value is checked by the caller, as this is likely to result - * in cleaner code. + * Consider using pm_runtime_resume_and_get() instead of it if its return + * value is checked by the caller, as this is likely to result in cleaner code. */ static inline int pm_runtime_get_sync(struct device *dev) {@@ -401,7 +400,7 @@ static inline int pm_runtime_get_sync(struct device *dev) * PM usage counter. Return 0 if the runtime PM usage counter of @dev has been * incremented or a negative error code otherwise. */ -static inline int pm_runtime_resume_and_get(struct device *dev) +static inline __must_check int pm_runtime_resume_and_get(struct device *dev) { int ret; --
Applied as 5.17 material, thanks!