can: bcm: fix hrtimer/tasklet termination in bcm op removal

When removing a bcm tx operation either a hrtimer or a tasklet might run.
As the hrtimer triggers its associated tasklet and vice versa we need to
take care to mutually terminate both handlers.

Reported-by: Michael Josenhans <michael.josenhans@web.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Tested-by: Michael Josenhans <michael.josenhans@web.de>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
Oliver Hartkopp 2017-01-18 21:30:51 +01:00 committed by Marc Kleine-Budde
parent d1156b489f
commit a06393ed03
1 changed files with 16 additions and 7 deletions

View File

@ -734,14 +734,23 @@ static struct bcm_op *bcm_find_op(struct list_head *ops,
static void bcm_remove_op(struct bcm_op *op) static void bcm_remove_op(struct bcm_op *op)
{ {
hrtimer_cancel(&op->timer); if (op->tsklet.func) {
hrtimer_cancel(&op->thrtimer); while (test_bit(TASKLET_STATE_SCHED, &op->tsklet.state) ||
test_bit(TASKLET_STATE_RUN, &op->tsklet.state) ||
hrtimer_active(&op->timer)) {
hrtimer_cancel(&op->timer);
tasklet_kill(&op->tsklet);
}
}
if (op->tsklet.func) if (op->thrtsklet.func) {
tasklet_kill(&op->tsklet); while (test_bit(TASKLET_STATE_SCHED, &op->thrtsklet.state) ||
test_bit(TASKLET_STATE_RUN, &op->thrtsklet.state) ||
if (op->thrtsklet.func) hrtimer_active(&op->thrtimer)) {
tasklet_kill(&op->thrtsklet); hrtimer_cancel(&op->thrtimer);
tasklet_kill(&op->thrtsklet);
}
}
if ((op->frames) && (op->frames != &op->sframe)) if ((op->frames) && (op->frames != &op->sframe))
kfree(op->frames); kfree(op->frames);