If rapl_package_register_powercap() fails in rapl_add_package() the
function happily returns 0.
Capture the error code and propagate it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
/* called from CPU hotplug notifier, hotplug lock held */
static int rapl_add_package(int cpu)
{
- int ret = 0;
- int phy_package_id;
struct rapl_package *rp;
+ int ret, phy_package_id;
phy_package_id = topology_physical_package_id(cpu);
rp = kzalloc(sizeof(struct rapl_package), GFP_KERNEL);
ret = -ENODEV;
goto err_free_package;
}
- if (!rapl_package_register_powercap(rp)) {
+ ret = rapl_package_register_powercap(rp);
+ if (!ret) {
INIT_LIST_HEAD(&rp->plist);
list_add(&rp->plist, &rapl_packages);
- return ret;
+ return 0;
}
err_free_package: