Skip to content

Commit 86eed2a

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: Fix order of freeing resources in pwmchip_remove()
pwmchip_add() calls of_pwmchip_add() only after adding the chip to pwm_chips and releasing pwm_lock. So the proper order in pwmchip_remove() is to call of_pwmchip_remove() before taking the mutex and removing the chip from pwm_chips. This way pwmchip_remove() releases the resources in reverse order compared to pwmchip_add() requesting them. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
1 parent 387c74e commit 86eed2a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/pwm/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ void pwmchip_remove(struct pwm_chip *chip)
318318
{
319319
pwmchip_sysfs_unexport(chip);
320320

321+
if (IS_ENABLED(CONFIG_OF))
322+
of_pwmchip_remove(chip);
323+
321324
mutex_lock(&pwm_lock);
322325

323326
list_del_init(&chip->list);
324327

325-
if (IS_ENABLED(CONFIG_OF))
326-
of_pwmchip_remove(chip);
327-
328328
free_pwms(chip);
329329

330330
mutex_unlock(&pwm_lock);

0 commit comments

Comments
 (0)