summaryrefslogtreecommitdiffstats
path: root/drivers/powercap
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2017-05-10 22:40:06 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-05-14 13:30:05 +0200
commit216c4e9db4c9d1d2a382b42880442dc632cd47d9 (patch)
tree68c8fc3ef185f9da03feacfec23c79b314c58650 /drivers/powercap
parent4486740da2e1cb307f58e0e62f94c92ec7c101a1 (diff)
downloadop-kernel-dev-216c4e9db4c9d1d2a382b42880442dc632cd47d9.zip
op-kernel-dev-216c4e9db4c9d1d2a382b42880442dc632cd47d9.tar.gz
PowerCap: Fix an error code in powercap_register_zone()
In the current code we accidentally return the successful result from idr_alloc() instead of a negative error pointer. The caller is looking for an error pointer and so it treats the returned value as a valid pointer. This one might be a bit serious because if it lets people get around the kernel's protection for remapping NULL. I'm not sure. Fixes: 75d2364ea0ca (PowerCap: Add class driver) Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/powercap')
-rw-r--r--drivers/powercap/powercap_sys.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
index 14bde0d..5b10b50 100644
--- a/drivers/powercap/powercap_sys.c
+++ b/drivers/powercap/powercap_sys.c
@@ -538,6 +538,7 @@ struct powercap_zone *powercap_register_zone(
power_zone->id = result;
idr_init(&power_zone->idr);
+ result = -ENOMEM;
power_zone->name = kstrdup(name, GFP_KERNEL);
if (!power_zone->name)
goto err_name_alloc;
OpenPOWER on IntegriCloud