Skip to content

Commit

Permalink
Input: atkbd - fix canceling event_work in disconnect
Browse files Browse the repository at this point in the history
We need to first unregister input device and only then cancel event work
since events can arrive (and cause event work to get scheduled again)
until input_unregister_device() returns.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Dmitry Torokhov committed Jan 6, 2010
1 parent 59b0151 commit 0ef7a26
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/input/keyboard/atkbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,16 @@ static void atkbd_disconnect(struct serio *serio)

atkbd_disable(atkbd);

/* make sure we don't have a command in flight */
input_unregister_device(atkbd->dev);

/*
* Make sure we don't have a command in flight.
* Note that since atkbd->enabled is false event work will keep
* rescheduling itself until it gets canceled and will not try
* accessing freed input device or serio port.
*/
cancel_delayed_work_sync(&atkbd->event_work);

input_unregister_device(atkbd->dev);
serio_close(serio);
serio_set_drvdata(serio, NULL);
kfree(atkbd);
Expand Down

0 comments on commit 0ef7a26

Please sign in to comment.