Skip to content

Commit

Permalink
Input: walkera0701 - fix crash on startup
Browse files Browse the repository at this point in the history
The driver's timer must be set up before enabling IRQ handler, otherwise
bad things may happen.

Reported-and-tested-by: Fengguang Wu <[email protected]>
Signed-off-by: Peter Popovec <[email protected]>
CC: [email protected]
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
Peter Popovec authored and dtor committed Dec 17, 2012
1 parent da5ee07 commit a455e29
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/input/joystick/walkera0701.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ static void walkera0701_close(struct input_dev *dev)
struct walkera_dev *w = input_get_drvdata(dev);

parport_disable_irq(w->parport);
hrtimer_cancel(&w->timer);
}

static int walkera0701_connect(struct walkera_dev *w, int parport)
Expand Down Expand Up @@ -224,6 +225,9 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)
if (parport_claim(w->pardevice))
goto init_err1;

hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
w->timer.function = timer_handler;

w->input_dev = input_allocate_device();
if (!w->input_dev)
goto init_err2;
Expand Down Expand Up @@ -254,8 +258,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)
if (err)
goto init_err3;

hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
w->timer.function = timer_handler;
return 0;

init_err3:
Expand All @@ -271,7 +273,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)

static void walkera0701_disconnect(struct walkera_dev *w)
{
hrtimer_cancel(&w->timer);
input_unregister_device(w->input_dev);
parport_release(w->pardevice);
parport_unregister_device(w->pardevice);
Expand Down

0 comments on commit a455e29

Please sign in to comment.