PowerCap: Fix an error code in powercap_register_zone()
[ Upstream commit216c4e9db4
] 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:75d2364ea0
(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> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
69df2501c0
commit
d6701d258d
@ -538,6 +538,7 @@ struct powercap_zone *powercap_register_zone(
|
|||||||
|
|
||||||
power_zone->id = result;
|
power_zone->id = result;
|
||||||
idr_init(&power_zone->idr);
|
idr_init(&power_zone->idr);
|
||||||
|
result = -ENOMEM;
|
||||||
power_zone->name = kstrdup(name, GFP_KERNEL);
|
power_zone->name = kstrdup(name, GFP_KERNEL);
|
||||||
if (!power_zone->name)
|
if (!power_zone->name)
|
||||||
goto err_name_alloc;
|
goto err_name_alloc;
|
||||||
|
Reference in New Issue
Block a user