[Bug] ARM: cpuidle: possible memleak

Daniel Lezcano daniel.lezcano at linaro.org
Tue Aug 29 02:04:43 PDT 2017


On 26/08/2017 13:46, Stefan Wahren wrote:

[ ... ]

>> diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
>> index 7080c38..827ab25 100644
>> --- a/drivers/cpuidle/cpuidle-arm.c
>> +++ b/drivers/cpuidle/cpuidle-arm.c
>> @@ -104,12 +104,14 @@ static int __init arm_idle_init(void)
>>  		ret = dt_init_idle_driver(drv, arm_idle_state_match, 1);
>>  		if (ret <= 0) {
>>  			ret = ret ? : -ENODEV;
>> +			kfree(drv);
>>  			goto out_fail;
>>  		}
>>  
>>  		ret = cpuidle_register_driver(drv);
>>  		if (ret) {
>>  			pr_err("Failed to register cpuidle driver\n");
>> +			kfree(drv);
>>  			goto out_fail;
>>  		}

I would prefer if you create another label on top of out_fail to free
'drv' and 'dev'. So you can remove the kfree in this loop (also take the
opportunity to remove the pr_err("Failed to allocate cpuidle device")
message.

> should i split this patch (fix for "my" memleak and cleanup fix)?

Yes, please.

Thanks.

  -- Daniel

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog




More information about the linux-arm-kernel mailing list