diff mbox series

[next] powercap: intel_rapl: Change an error pointer to NULL

Message ID fa719c6a-8d3b-4cca-9b43-bcd477ff6655@stanley.mountain (mailing list archive)
State Mainlined, archived
Headers show
Series [next] powercap: intel_rapl: Change an error pointer to NULL | expand

Commit Message

Dan Carpenter Aug. 23, 2024, 12:51 p.m. UTC
The rapl_find_package_domain_cpuslocked() function is supposed to
return NULL on error.  This new error patch returns ERR_PTR(-EINVAL) but
none of the callers check for that so it would lead to an Oops.

Fixes: 26096aed255f ("powercap/intel_rapl: Fix the energy-pkg event for AMD CPUs")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/powercap/intel_rapl_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rafael J. Wysocki Aug. 23, 2024, 1:47 p.m. UTC | #1
On Fri, Aug 23, 2024 at 2:51 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The rapl_find_package_domain_cpuslocked() function is supposed to
> return NULL on error.  This new error patch returns ERR_PTR(-EINVAL) but
> none of the callers check for that so it would lead to an Oops.
>
> Fixes: 26096aed255f ("powercap/intel_rapl: Fix the energy-pkg event for AMD CPUs")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/powercap/intel_rapl_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
> index d110c5da5cfe..2881687d7900 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -2157,7 +2157,7 @@ struct rapl_package *rapl_find_package_domain_cpuslocked(int id, struct rapl_if_
>                       topology_physical_package_id(id) : topology_logical_die_id(id);
>                 if (uid < 0) {
>                         pr_err("topology_logical_(package/die)_id() returned a negative value");
> -                       return ERR_PTR(-EINVAL);
> +                       return NULL;
>                 }
>         }
>         else
> --

Applied, thank you!
diff mbox series

Patch

diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
index d110c5da5cfe..2881687d7900 100644
--- a/drivers/powercap/intel_rapl_common.c
+++ b/drivers/powercap/intel_rapl_common.c
@@ -2157,7 +2157,7 @@  struct rapl_package *rapl_find_package_domain_cpuslocked(int id, struct rapl_if_
 		      topology_physical_package_id(id) : topology_logical_die_id(id);
 		if (uid < 0) {
 			pr_err("topology_logical_(package/die)_id() returned a negative value");
-			return ERR_PTR(-EINVAL);
+			return NULL;
 		}
 	}
 	else