| From 793dd5d19379dfe909ddfe86068965d4c2eb6c48 Mon Sep 17 00:00:00 2001 |
| From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de> |
| Date: Mon, 11 Nov 2019 10:03:54 +0100 |
| Subject: [PATCH] pwm: omap-dmtimer: Remove PWM chip in .remove before making |
| it unfunctional |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| commit 43efdc8f0e6d7088ec61bd55a73bf853f002d043 upstream. |
| |
| In the old code (e.g.) mutex_destroy() was called before |
| pwmchip_remove(). Between these two calls it is possible that a PWM |
| callback is used which tries to grab the mutex. |
| |
| Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") |
| Signed-off-by: Uwe Kleine-Kรถnig <u.kleine-koenig@pengutronix.de> |
| Signed-off-by: Thierry Reding <thierry.reding@gmail.com> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c |
| index 6cfeb0e1cc67..e36fcad668a6 100644 |
| --- a/drivers/pwm/pwm-omap-dmtimer.c |
| +++ b/drivers/pwm/pwm-omap-dmtimer.c |
| @@ -361,6 +361,11 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev) |
| static int pwm_omap_dmtimer_remove(struct platform_device *pdev) |
| { |
| struct pwm_omap_dmtimer_chip *omap = platform_get_drvdata(pdev); |
| + int ret; |
| + |
| + ret = pwmchip_remove(&omap->chip); |
| + if (ret) |
| + return ret; |
| |
| if (pm_runtime_active(&omap->dm_timer_pdev->dev)) |
| omap->pdata->stop(omap->dm_timer); |
| @@ -369,7 +374,7 @@ static int pwm_omap_dmtimer_remove(struct platform_device *pdev) |
| |
| mutex_destroy(&omap->mutex); |
| |
| - return pwmchip_remove(&omap->chip); |
| + return 0; |
| } |
| |
| static const struct of_device_id pwm_omap_dmtimer_of_match[] = { |
| -- |
| 2.7.4 |
| |