[PATCH 3/9] power: supply: max77705: Free allocated workqueue and fix removal order

Krzysztof Kozlowski krzk at kernel.org
Mon Feb 23 02:19:13 PST 2026


On 23/02/2026 09:57, Andy Shevchenko wrote:
> On Mon, Feb 23, 2026 at 08:27:31AM +0100, Krzysztof Kozlowski wrote:
>> Use devm interface for allocating workqueue to fix two bugs at the same
>> time:
>>
>> 1. Driver leaks the memory on remove(), because the workqueue is not
>>    destroyed.
>>
>> 2. Driver allocates workqueue and then registers interrupt handlers
>>    with devm interface.  This means that probe error paths will not use a
>>    reversed order, but first the destroy workqueue and then, via devm
>>    release handlers, free the interrupt.
>>
>>    The interrupt handler schedules work on this exact workqueue, thus if
>>    interrupt is hit in this short time window - after destroying
>>    workqueue, but before devm() frees the interrupt, the work scheduling
>>    will lead to use of freed memory.
> 
> ...
> 
>>  	ret = devm_request_threaded_irq(dev, regmap_irq_get_virq(irq_data, MAX77705_CHGIN_I),
>>  					NULL, max77705_chgin_irq,
>>  					IRQF_TRIGGER_NONE,
>>  					"chgin-irq", chg);
>> -	if (ret) {
>> -		dev_err_probe(dev, ret, "Failed to Request chgin IRQ\n");
>> -		goto destroy_wq;
>> -	}
>> +	if (ret)
>> +		return dev_err_probe(dev, ret, "Failed to Request chgin IRQ\n");
> 
> This should be just
> 
> 		return ret;
> 
> 
> devm_*_irq() prints the message. No need to repeat this in the caller(s).
> 

I guess separate commit then.

Best regards,
Krzysztof



More information about the linux-arm-kernel mailing list