aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-10-14 11:23:56 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-21 05:54:01 -0400
commitb4d752b308493b08b51ea04361848ef63d0cad42 (patch)
tree9e74d74471f5a1e80f37c80648e271c5ed2604a1
parentb784cfcec7293f688b09d3850826216a4e134d2e (diff)
[media] ir: avoid race conditions at device disconnect
It is possible that, while ir_unregister_class() is handling, some application could try to access the sysfs nodes, causing an OOPS. Reviewed-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/IR/ir-sysfs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index be09d1995b41..186807aa226d 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -68,6 +68,10 @@ static ssize_t show_protocols(struct device *d,
68 char *tmp = buf; 68 char *tmp = buf;
69 int i; 69 int i;
70 70
71 /* Device is being removed */
72 if (!ir_dev)
73 return -EINVAL;
74
71 if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { 75 if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) {
72 enabled = ir_dev->rc_tab.ir_type; 76 enabled = ir_dev->rc_tab.ir_type;
73 allowed = ir_dev->props->allowed_protos; 77 allowed = ir_dev->props->allowed_protos;
@@ -123,6 +127,10 @@ static ssize_t store_protocols(struct device *d,
123 int rc, i, count = 0; 127 int rc, i, count = 0;
124 unsigned long flags; 128 unsigned long flags;
125 129
130 /* Device is being removed */
131 if (!ir_dev)
132 return -EINVAL;
133
126 if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) 134 if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE)
127 type = ir_dev->rc_tab.ir_type; 135 type = ir_dev->rc_tab.ir_type;
128 else if (ir_dev->raw) 136 else if (ir_dev->raw)
@@ -310,6 +318,7 @@ void ir_unregister_class(struct input_dev *input_dev)
310{ 318{
311 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); 319 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
312 320
321 input_set_drvdata(input_dev, NULL);
313 clear_bit(ir_dev->devno, &ir_core_dev_number); 322 clear_bit(ir_dev->devno, &ir_core_dev_number);
314 input_unregister_device(input_dev); 323 input_unregister_device(input_dev);
315 device_del(&ir_dev->dev); 324 device_del(&ir_dev->dev);