]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
power: supply: max77705: Free allocated workqueue and fix removal order
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Thu, 5 Mar 2026 21:45:43 +0000 (22:45 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 11 Mar 2026 05:58:00 +0000 (06:58 +0100)
commit1e668baadefb16e81269dbfebf3ffc2672e3a3bb
tree7eda6a237bed269e24aa7b6289c543f5c08501b3
parent2064c64ceb1996ee02a6bbb1de05fd6e8028e3e4
power: supply: max77705: Free allocated workqueue and fix removal order

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 destroy the 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 schedulled
   work will lead to use of freed memory.

Change is not equivalent in the workqueue itself: use non-legacy API
which does not set (__WQ_LEGACY | WQ_MEM_RECLAIM).  The workqueue is
used to update power supply (power_supply_changed()) status, thus there
is no point to run it for memory reclaim.  Note that dev_name() is not
directly used in second argument to prevent possible unlikely parsing
any "%" character in device name as format.

Fixes: 11741b8e382d ("power: supply: max77705: Fix workqueue error handling in probe")
Fixes: a6a494c8e3ce ("power: supply: max77705: Add charger driver for Maxim 77705")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260305-workqueue-devm-v2-4-66a38741c652@oss.qualcomm.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/max77705_charger.c