Commit b4d752b3 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[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: default avatarJarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b784cfce
...@@ -68,6 +68,10 @@ static ssize_t show_protocols(struct device *d, ...@@ -68,6 +68,10 @@ static ssize_t show_protocols(struct device *d,
char *tmp = buf; char *tmp = buf;
int i; int i;
/* Device is being removed */
if (!ir_dev)
return -EINVAL;
if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) { if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) {
enabled = ir_dev->rc_tab.ir_type; enabled = ir_dev->rc_tab.ir_type;
allowed = ir_dev->props->allowed_protos; allowed = ir_dev->props->allowed_protos;
...@@ -123,6 +127,10 @@ static ssize_t store_protocols(struct device *d, ...@@ -123,6 +127,10 @@ static ssize_t store_protocols(struct device *d,
int rc, i, count = 0; int rc, i, count = 0;
unsigned long flags; unsigned long flags;
/* Device is being removed */
if (!ir_dev)
return -EINVAL;
if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE) if (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_SCANCODE)
type = ir_dev->rc_tab.ir_type; type = ir_dev->rc_tab.ir_type;
else if (ir_dev->raw) else if (ir_dev->raw)
...@@ -310,6 +318,7 @@ void ir_unregister_class(struct input_dev *input_dev) ...@@ -310,6 +318,7 @@ void ir_unregister_class(struct input_dev *input_dev)
{ {
struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
input_set_drvdata(input_dev, NULL);
clear_bit(ir_dev->devno, &ir_core_dev_number); clear_bit(ir_dev->devno, &ir_core_dev_number);
input_unregister_device(input_dev); input_unregister_device(input_dev);
device_del(&ir_dev->dev); device_del(&ir_dev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment