Skip to content

Commit 85fb980

Browse files
hartkoppgregkh
authored andcommitted
can: bcm: fix hrtimer/tasklet termination in bcm op removal
commit a06393ed03167771246c4c43192d9c264bc48412 upstream. 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> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4025ab3 commit 85fb980

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

net/can/bcm.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -710,14 +710,23 @@ static struct bcm_op *bcm_find_op(struct list_head *ops, canid_t can_id,
710710

711711
static void bcm_remove_op(struct bcm_op *op)
712712
{
713-
hrtimer_cancel(&op->timer);
714-
hrtimer_cancel(&op->thrtimer);
715-
716-
if (op->tsklet.func)
717-
tasklet_kill(&op->tsklet);
713+
if (op->tsklet.func) {
714+
while (test_bit(TASKLET_STATE_SCHED, &op->tsklet.state) ||
715+
test_bit(TASKLET_STATE_RUN, &op->tsklet.state) ||
716+
hrtimer_active(&op->timer)) {
717+
hrtimer_cancel(&op->timer);
718+
tasklet_kill(&op->tsklet);
719+
}
720+
}
718721

719-
if (op->thrtsklet.func)
720-
tasklet_kill(&op->thrtsklet);
722+
if (op->thrtsklet.func) {
723+
while (test_bit(TASKLET_STATE_SCHED, &op->thrtsklet.state) ||
724+
test_bit(TASKLET_STATE_RUN, &op->thrtsklet.state) ||
725+
hrtimer_active(&op->thrtimer)) {
726+
hrtimer_cancel(&op->thrtimer);
727+
tasklet_kill(&op->thrtsklet);
728+
}
729+
}
721730

722731
if ((op->frames) && (op->frames != &op->sframe))
723732
kfree(op->frames);

0 commit comments

Comments
 (0)