PowerCap: Fix an error code in powercap_register_zone()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 10 May 2017 19:40:06 +0000 (22:40 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Apr 2018 17:47:56 +0000 (19:47 +0200)
commitd6701d258d3c916aca4515c9d32dc7340b0e22b4
tree41381b5f7cfc3aa2fc778863f8e76993493e8d04
parent69df2501c0902550d45f0b762788df7b9ab89bf6
PowerCap: Fix an error code in powercap_register_zone()

[ Upstream commit 216c4e9db4c9d1d2a382b42880442dc632cd47d9 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/powercap/powercap_sys.c