diff options
author | Douglas Bagnall <douglas@paradise.net.nz> | 2012-07-06 22:27:57 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-30 20:15:32 -0400 |
commit | 720bb6436ff30fccad05cf5bdf961ea5b1f5686d (patch) | |
tree | 55856eb142941b786962a34f64e81937616ce663 /drivers/media | |
parent | 8f695d3f07bf9fd2914d18d1d2f89e3574b809ff (diff) |
[media] Avoid sysfs oops when an rc_dev's raw device is absent
For some reason, when the lirc daemon learns that a usb remote control
has been unplugged, it wants to read the sysfs attributes of the
disappearing device. This is useful for uncovering transient
inconsistencies, but less so for keeping the system running when such
inconsistencies exist.
Under some circumstances (like every time I unplug my dvb stick from
my laptop), lirc catches an rc_dev whose raw event handler has been
removed (presumably by ir_raw_event_unregister), and proceeds to
interrogate the raw protocols supported by the NULL pointer.
This patch avoids the NULL dereference, and ignores the issue of how
this state of affairs came about in the first place.
Version 2 incorporates changes recommended by Mauro Carvalho Chehab
(-ENODEV instead of -EINVAL, and a signed-off-by).
Signed-off-by: Douglas Bagnall <douglas@paradise.net.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/rc/rc-main.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 6e16b09c24a9..cabc19c10515 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -775,10 +775,11 @@ static ssize_t show_protocols(struct device *device, | |||
775 | if (dev->driver_type == RC_DRIVER_SCANCODE) { | 775 | if (dev->driver_type == RC_DRIVER_SCANCODE) { |
776 | enabled = dev->rc_map.rc_type; | 776 | enabled = dev->rc_map.rc_type; |
777 | allowed = dev->allowed_protos; | 777 | allowed = dev->allowed_protos; |
778 | } else { | 778 | } else if (dev->raw) { |
779 | enabled = dev->raw->enabled_protocols; | 779 | enabled = dev->raw->enabled_protocols; |
780 | allowed = ir_raw_get_allowed_protocols(); | 780 | allowed = ir_raw_get_allowed_protocols(); |
781 | } | 781 | } else |
782 | return -ENODEV; | ||
782 | 783 | ||
783 | IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n", | 784 | IR_dprintk(1, "allowed - 0x%llx, enabled - 0x%llx\n", |
784 | (long long)allowed, | 785 | (long long)allowed, |