powercap/drivers/dtpm: Fix an IS_ERR() vs NULL check
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 6 Jan 2021 09:03:08 +0000 (12:03 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 7 Jan 2021 17:13:51 +0000 (18:13 +0100)
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>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/powercap/dtpm.c

index 470a118..5a51cd3 100644 (file)
@@ -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)