diff mbox series

[3/3] powercap/drivers/dtpm: Fix an IS_ERR() vs NULL check

Message ID X/V8zHPwlGiSxq1M@mwanda (mailing list archive)
State Mainlined, archived
Headers show
Series [1/3] powercap/drivers/dtpm: Fix a double shift bug | expand

Commit Message

Dan Carpenter Jan. 6, 2021, 9:03 a.m. UTC
The powercap_register_control_type() function never returns NULL, it
returns error pointers on error so update this check.

Fixes: a20d0ef97abf ("powercap/drivers/dtpm: Add API for dynamic thermal power management")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/powercap/dtpm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Daniel Lezcano Jan. 7, 2021, 5:03 p.m. UTC | #1
On 06/01/2021 10:03, Dan Carpenter wrote:
> The powercap_register_control_type() function never returns NULL, it
> returns error pointers on error so update this check.
> 
> Fixes: a20d0ef97abf ("powercap/drivers/dtpm: Add API for dynamic thermal power management")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Thanks for these fixes.

  --Daniel

> ---
>  drivers/powercap/dtpm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c
> index 470a1182b868..5a51cd34a7e8 100644
> --- a/drivers/powercap/dtpm.c
> +++ b/drivers/powercap/dtpm.c
> @@ -467,9 +467,9 @@ static int __init dtpm_init(void)
>  	struct dtpm_descr **dtpm_descr;
>  
>  	pct = powercap_register_control_type(NULL, "dtpm", NULL);
> -	if (!pct) {
> +	if (IS_ERR(pct)) {
>  		pr_err("Failed to register control type\n");
> -		return -EINVAL;
> +		return PTR_ERR(pct);
>  	}
>  
>  	for_each_dtpm_table(dtpm_descr)
>
Rafael J. Wysocki Jan. 7, 2021, 5:19 p.m. UTC | #2
On Thu, Jan 7, 2021 at 6:04 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>
> On 06/01/2021 10:03, Dan Carpenter wrote:
> > The powercap_register_control_type() function never returns NULL, it
> > returns error pointers on error so update this check.
> >
> > Fixes: a20d0ef97abf ("powercap/drivers/dtpm: Add API for dynamic thermal power management")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>
> Thanks for these fixes.

All 3 patches applied, but as the original DTPM changes have not made
it into 5.11-rc, all of this is 5.12 material now.
diff mbox series

Patch

diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c
index 470a1182b868..5a51cd34a7e8 100644
--- a/drivers/powercap/dtpm.c
+++ b/drivers/powercap/dtpm.c
@@ -467,9 +467,9 @@  static int __init dtpm_init(void)
 	struct dtpm_descr **dtpm_descr;
 
 	pct = powercap_register_control_type(NULL, "dtpm", NULL);
-	if (!pct) {
+	if (IS_ERR(pct)) {
 		pr_err("Failed to register control type\n");
-		return -EINVAL;
+		return PTR_ERR(pct);
 	}
 
 	for_each_dtpm_table(dtpm_descr)