]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mfd: cs42l43: Fix issues in probe error paths
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Wed, 2 Oct 2024 12:13:11 +0000 (13:13 +0100)
committerLee Jones <lee@kernel.org>
Wed, 16 Oct 2024 08:04:10 +0000 (09:04 +0100)
The error path in cs42l43_boot_work() will lead to an unbalanced
regulator put, when the driver is removed. Fix this by relying
on remove to power down the device. Also the boot work needs to
be synchronised with driver remove, to ensure the work is not
still running after the driver has been removed. Add the required
cancel_work_sync().

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20241002121311.162691-1-ckeepax@opensource.cirrus.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/cs42l43.c

index ae8fd37afb75486d7d376f76a93e130d7065f10c..3b4efb29447136d5b6d6463b1cf28b9e92158777 100644 (file)
@@ -967,7 +967,6 @@ static void cs42l43_boot_work(struct work_struct *work)
 
 err:
        pm_runtime_put_sync(cs42l43->dev);
-       cs42l43_dev_remove(cs42l43);
 }
 
 static int cs42l43_power_up(struct cs42l43 *cs42l43)
@@ -1101,6 +1100,8 @@ EXPORT_SYMBOL_NS_GPL(cs42l43_dev_probe, MFD_CS42L43);
 
 void cs42l43_dev_remove(struct cs42l43 *cs42l43)
 {
+       cancel_work_sync(&cs42l43->boot_work);
+
        cs42l43_power_down(cs42l43);
 }
 EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);