Message ID | 20230725081004.395798-1-u.kleine-koenig@pengutronix.de |
---|---|
State | Accepted |
Headers | show |
Series | pwm: Fix order of freeing resources in pwmchip_remove() | expand |
On Tue, 25 Jul 2023 10:10:04 +0200, Uwe Kleine-König wrote: > 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. > > [...] Applied, thanks! [1/1] pwm: Fix order of freeing resources in pwmchip_remove() commit: 86eed2a10304a9efe56c2b192b914b377cad260d Best regards,
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 3dacceaef4a9..3639d84c492d 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -321,13 +321,13 @@ void pwmchip_remove(struct pwm_chip *chip) { pwmchip_sysfs_unexport(chip); + if (IS_ENABLED(CONFIG_OF)) + of_pwmchip_remove(chip); + mutex_lock(&pwm_lock); list_del_init(&chip->list); - if (IS_ENABLED(CONFIG_OF)) - of_pwmchip_remove(chip); - free_pwms(chip); mutex_unlock(&pwm_lock);
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> --- Hello, I didn't spot a real problem that is fixed here, so this is only for the sake of consistency. Best regards Uwe drivers/pwm/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)