mirror of
https://github.com/armbian/linux-cix.git
synced 2026-01-06 12:30:45 -08:00
treewide: Convert del_timer*() to timer_shutdown*()
Due to several bugs caused by timers being re-armed after they are
shutdown and just before they are freed, a new state of timers was added
called "shutdown". After a timer is set to this state, then it can no
longer be re-armed.
The following script was run to find all the trivial locations where
del_timer() or del_timer_sync() is called in the same function that the
object holding the timer is freed. It also ignores any locations where
the timer->function is modified between the del_timer*() and the free(),
as that is not considered a "trivial" case.
This was created by using a coccinelle script and the following
commands:
$ cat timer.cocci
@@
expression ptr, slab;
identifier timer, rfield;
@@
(
- del_timer(&ptr->timer);
+ timer_shutdown(&ptr->timer);
|
- del_timer_sync(&ptr->timer);
+ timer_shutdown_sync(&ptr->timer);
)
... when strict
when != ptr->timer
(
kfree_rcu(ptr, rfield);
|
kmem_cache_free(slab, ptr);
|
kfree(ptr);
)
$ spatch timer.cocci . > /tmp/t.patch
$ patch -p1 < /tmp/t.patch
Link: https://lore.kernel.org/lkml/20221123201306.823305113@linutronix.de/
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Acked-by: Pavel Machek <pavel@ucw.cz> [ LED ]
Acked-by: Kalle Valo <kvalo@kernel.org> [ wireless ]
Acked-by: Paolo Abeni <pabeni@redhat.com> [ networking ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
72a85e2b0a
commit
292a089d78
@@ -102,7 +102,7 @@ static int switch_drv_remove(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
flush_work(&psw->work);
|
||||
del_timer_sync(&psw->debounce);
|
||||
timer_shutdown_sync(&psw->debounce);
|
||||
free_irq(irq, pdev);
|
||||
|
||||
kfree(psw);
|
||||
|
||||
@@ -2820,7 +2820,7 @@ static void ioc_rqos_exit(struct rq_qos *rqos)
|
||||
ioc->running = IOC_STOP;
|
||||
spin_unlock_irq(&ioc->lock);
|
||||
|
||||
del_timer_sync(&ioc->timer);
|
||||
timer_shutdown_sync(&ioc->timer);
|
||||
free_percpu(ioc->pcpu_stat);
|
||||
kfree(ioc);
|
||||
}
|
||||
|
||||
@@ -644,7 +644,7 @@ static void blkcg_iolatency_exit(struct rq_qos *rqos)
|
||||
{
|
||||
struct blk_iolatency *blkiolat = BLKIOLATENCY(rqos);
|
||||
|
||||
del_timer_sync(&blkiolat->timer);
|
||||
timer_shutdown_sync(&blkiolat->timer);
|
||||
flush_work(&blkiolat->enable_work);
|
||||
blkcg_deactivate_policy(rqos->q, &blkcg_policy_iolatency);
|
||||
kfree(blkiolat);
|
||||
|
||||
@@ -434,7 +434,7 @@ static void kyber_exit_sched(struct elevator_queue *e)
|
||||
struct kyber_queue_data *kqd = e->elevator_data;
|
||||
int i;
|
||||
|
||||
del_timer_sync(&kqd->timer);
|
||||
timer_shutdown_sync(&kqd->timer);
|
||||
blk_stat_disable_accounting(kqd->q);
|
||||
|
||||
for (i = 0; i < KYBER_NUM_DOMAINS; i++)
|
||||
|
||||
@@ -1431,7 +1431,7 @@ static int ghes_remove(struct platform_device *ghes_dev)
|
||||
ghes->flags |= GHES_EXITING;
|
||||
switch (generic->notify.type) {
|
||||
case ACPI_HEST_NOTIFY_POLLED:
|
||||
del_timer_sync(&ghes->timer);
|
||||
timer_shutdown_sync(&ghes->timer);
|
||||
break;
|
||||
case ACPI_HEST_NOTIFY_EXTERNAL:
|
||||
free_irq(ghes->irq, ghes);
|
||||
|
||||
@@ -2213,7 +2213,7 @@ idt77252_init_ubr(struct idt77252_dev *card, struct vc_map *vc,
|
||||
}
|
||||
spin_unlock_irqrestore(&vc->lock, flags);
|
||||
if (est) {
|
||||
del_timer_sync(&est->timer);
|
||||
timer_shutdown_sync(&est->timer);
|
||||
kfree(est);
|
||||
}
|
||||
|
||||
@@ -2530,7 +2530,7 @@ done:
|
||||
vc->tx_vcc = NULL;
|
||||
|
||||
if (vc->estimator) {
|
||||
del_timer(&vc->estimator->timer);
|
||||
timer_shutdown(&vc->estimator->timer);
|
||||
kfree(vc->estimator);
|
||||
vc->estimator = NULL;
|
||||
}
|
||||
@@ -3752,7 +3752,7 @@ static void __exit idt77252_exit(void)
|
||||
card = idt77252_chain;
|
||||
dev = card->atmdev;
|
||||
idt77252_chain = card->next;
|
||||
del_timer_sync(&card->tst_timer);
|
||||
timer_shutdown_sync(&card->tst_timer);
|
||||
|
||||
if (dev->phy->stop)
|
||||
dev->phy->stop(dev);
|
||||
|
||||
@@ -2184,7 +2184,7 @@ void drbd_destroy_device(struct kref *kref)
|
||||
struct drbd_resource *resource = device->resource;
|
||||
struct drbd_peer_device *peer_device, *tmp_peer_device;
|
||||
|
||||
del_timer_sync(&device->request_timer);
|
||||
timer_shutdown_sync(&device->request_timer);
|
||||
|
||||
/* paranoia asserts */
|
||||
D_ASSERT(device, device->open_cnt == 0);
|
||||
|
||||
@@ -1755,7 +1755,7 @@ static void lo_free_disk(struct gendisk *disk)
|
||||
if (lo->workqueue)
|
||||
destroy_workqueue(lo->workqueue);
|
||||
loop_free_idle_workers(lo, true);
|
||||
del_timer_sync(&lo->timer);
|
||||
timer_shutdown_sync(&lo->timer);
|
||||
mutex_destroy(&lo->lo_mutex);
|
||||
kfree(lo);
|
||||
}
|
||||
|
||||
@@ -737,7 +737,7 @@ static int bcsp_close(struct hci_uart *hu)
|
||||
{
|
||||
struct bcsp_struct *bcsp = hu->priv;
|
||||
|
||||
del_timer_sync(&bcsp->tbcsp);
|
||||
timer_shutdown_sync(&bcsp->tbcsp);
|
||||
|
||||
hu->priv = NULL;
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ static void irq_i915_sw_fence_work(struct irq_work *wrk)
|
||||
struct i915_sw_dma_fence_cb_timer *cb =
|
||||
container_of(wrk, typeof(*cb), work);
|
||||
|
||||
del_timer_sync(&cb->timer);
|
||||
timer_shutdown_sync(&cb->timer);
|
||||
dma_fence_put(cb->dma);
|
||||
|
||||
kfree_rcu(cb, rcu);
|
||||
|
||||
@@ -1771,7 +1771,7 @@ static void wiimote_destroy(struct wiimote_data *wdata)
|
||||
spin_unlock_irqrestore(&wdata->state.lock, flags);
|
||||
|
||||
cancel_work_sync(&wdata->init_worker);
|
||||
del_timer_sync(&wdata->timer);
|
||||
timer_shutdown_sync(&wdata->timer);
|
||||
|
||||
device_remove_file(&wdata->hdev->dev, &dev_attr_devtype);
|
||||
device_remove_file(&wdata->hdev->dev, &dev_attr_extension);
|
||||
|
||||
@@ -310,7 +310,7 @@ static void locomokbd_remove(struct locomo_dev *dev)
|
||||
|
||||
free_irq(dev->irq[0], locomokbd);
|
||||
|
||||
del_timer_sync(&locomokbd->timer);
|
||||
timer_shutdown_sync(&locomokbd->timer);
|
||||
|
||||
input_unregister_device(locomokbd->input);
|
||||
locomo_set_drvdata(dev, NULL);
|
||||
|
||||
@@ -296,7 +296,7 @@ static int omap_kp_remove(struct platform_device *pdev)
|
||||
omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
|
||||
free_irq(omap_kp->irq, omap_kp);
|
||||
|
||||
del_timer_sync(&omap_kp->timer);
|
||||
timer_shutdown_sync(&omap_kp->timer);
|
||||
tasklet_kill(&kp_tasklet);
|
||||
|
||||
/* unregister everything */
|
||||
|
||||
@@ -2970,7 +2970,7 @@ static void alps_disconnect(struct psmouse *psmouse)
|
||||
struct alps_data *priv = psmouse->private;
|
||||
|
||||
psmouse_reset(psmouse);
|
||||
del_timer_sync(&priv->timer);
|
||||
timer_shutdown_sync(&priv->timer);
|
||||
if (priv->dev2)
|
||||
input_unregister_device(priv->dev2);
|
||||
if (!IS_ERR_OR_NULL(priv->dev3))
|
||||
|
||||
@@ -1236,8 +1236,8 @@ release_card(struct l1oip *hc)
|
||||
|
||||
hc->shutdown = true;
|
||||
|
||||
del_timer_sync(&hc->keep_tl);
|
||||
del_timer_sync(&hc->timeout_tl);
|
||||
timer_shutdown_sync(&hc->keep_tl);
|
||||
timer_shutdown_sync(&hc->timeout_tl);
|
||||
|
||||
cancel_work_sync(&hc->workq);
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ mISDN_close(struct inode *ino, struct file *filep)
|
||||
while (!list_empty(list)) {
|
||||
timer = list_first_entry(list, struct mISDNtimer, list);
|
||||
spin_unlock_irq(&dev->lock);
|
||||
del_timer_sync(&timer->tl);
|
||||
timer_shutdown_sync(&timer->tl);
|
||||
spin_lock_irq(&dev->lock);
|
||||
/* it might have been moved to ->expired */
|
||||
list_del(&timer->list);
|
||||
@@ -204,7 +204,7 @@ misdn_del_timer(struct mISDNtimerdev *dev, int id)
|
||||
list_del_init(&timer->list);
|
||||
timer->id = -1;
|
||||
spin_unlock_irq(&dev->lock);
|
||||
del_timer_sync(&timer->tl);
|
||||
timer_shutdown_sync(&timer->tl);
|
||||
kfree(timer);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ static void activity_deactivate(struct led_classdev *led_cdev)
|
||||
{
|
||||
struct activity_data *activity_data = led_get_trigger_data(led_cdev);
|
||||
|
||||
del_timer_sync(&activity_data->timer);
|
||||
timer_shutdown_sync(&activity_data->timer);
|
||||
kfree(activity_data);
|
||||
clear_bit(LED_BLINK_SW, &led_cdev->work_flags);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ static void heartbeat_trig_deactivate(struct led_classdev *led_cdev)
|
||||
struct heartbeat_trig_data *heartbeat_data =
|
||||
led_get_trigger_data(led_cdev);
|
||||
|
||||
del_timer_sync(&heartbeat_data->timer);
|
||||
timer_shutdown_sync(&heartbeat_data->timer);
|
||||
kfree(heartbeat_data);
|
||||
clear_bit(LED_BLINK_SW, &led_cdev->work_flags);
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ static void pattern_trig_deactivate(struct led_classdev *led_cdev)
|
||||
if (led_cdev->pattern_clear)
|
||||
led_cdev->pattern_clear(led_cdev);
|
||||
|
||||
del_timer_sync(&data->timer);
|
||||
timer_shutdown_sync(&data->timer);
|
||||
|
||||
led_set_brightness(led_cdev, LED_OFF);
|
||||
kfree(data);
|
||||
|
||||
@@ -180,7 +180,7 @@ static void transient_trig_deactivate(struct led_classdev *led_cdev)
|
||||
{
|
||||
struct transient_trig_data *transient_data = led_get_trigger_data(led_cdev);
|
||||
|
||||
del_timer_sync(&transient_data->timer);
|
||||
timer_shutdown_sync(&transient_data->timer);
|
||||
led_set_brightness_nosleep(led_cdev, transient_data->restore_state);
|
||||
kfree(transient_data);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user