提交 c1089bdc 编写于 作者: J Jean Delvare 提交者: Mauro Carvalho Chehab

V4L/DVB (10939): ir-kbd-i2c: Prevent general protection fault on rmmod

The removal of the timer which polls the infrared input is racy.
Replacing the timer with a delayed work solves the problem.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 f263bac9
...@@ -279,15 +279,9 @@ static void ir_key_poll(struct IR_i2c *ir) ...@@ -279,15 +279,9 @@ static void ir_key_poll(struct IR_i2c *ir)
} }
} }
static void ir_timer(unsigned long data)
{
struct IR_i2c *ir = (struct IR_i2c*)data;
schedule_work(&ir->work);
}
static void ir_work(struct work_struct *work) static void ir_work(struct work_struct *work)
{ {
struct IR_i2c *ir = container_of(work, struct IR_i2c, work); struct IR_i2c *ir = container_of(work, struct IR_i2c, work.work);
int polling_interval = 100; int polling_interval = 100;
/* MSI TV@nywhere Plus requires more frequent polling /* MSI TV@nywhere Plus requires more frequent polling
...@@ -296,7 +290,7 @@ static void ir_work(struct work_struct *work) ...@@ -296,7 +290,7 @@ static void ir_work(struct work_struct *work)
polling_interval = 50; polling_interval = 50;
ir_key_poll(ir); ir_key_poll(ir);
mod_timer(&ir->timer, jiffies + msecs_to_jiffies(polling_interval)); schedule_delayed_work(&ir->work, msecs_to_jiffies(polling_interval));
} }
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
...@@ -452,11 +446,8 @@ static int ir_attach(struct i2c_adapter *adap, int addr, ...@@ -452,11 +446,8 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
ir->input->name, ir->input->phys, adap->name); ir->input->name, ir->input->phys, adap->name);
/* start polling via eventd */ /* start polling via eventd */
INIT_WORK(&ir->work, ir_work); INIT_DELAYED_WORK(&ir->work, ir_work);
init_timer(&ir->timer); schedule_delayed_work(&ir->work, 0);
ir->timer.function = ir_timer;
ir->timer.data = (unsigned long)ir;
schedule_work(&ir->work);
return 0; return 0;
...@@ -473,8 +464,7 @@ static int ir_detach(struct i2c_client *client) ...@@ -473,8 +464,7 @@ static int ir_detach(struct i2c_client *client)
struct IR_i2c *ir = i2c_get_clientdata(client); struct IR_i2c *ir = i2c_get_clientdata(client);
/* kill outstanding polls */ /* kill outstanding polls */
del_timer_sync(&ir->timer); cancel_delayed_work_sync(&ir->work);
flush_scheduled_work();
/* unregister devices */ /* unregister devices */
input_unregister_device(ir->input); input_unregister_device(ir->input);
......
...@@ -14,8 +14,7 @@ struct IR_i2c { ...@@ -14,8 +14,7 @@ struct IR_i2c {
/* Used to avoid fast repeating */ /* Used to avoid fast repeating */
unsigned char old; unsigned char old;
struct work_struct work; struct delayed_work work;
struct timer_list timer;
char phys[32]; char phys[32];
int (*get_key)(struct IR_i2c*, u32*, u32*); int (*get_key)(struct IR_i2c*, u32*, u32*);
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册