Avoid sysfs oops when an rc_dev's raw device is absent
authorDouglas Bagnall <douglas@paradise.net.nz>
Sat, 7 Jul 2012 02:27:57 +0000 (23:27 -0300)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 6 Mar 2013 03:24:24 +0000 (03:24 +0000)
commit86e9259d57d7eb2fae2acf5539e782403b689efb
treef0b7c5638671698ea904b1ca4d72595766fb7476
parent91668663ec66998d18533c2d0fac4faef1a08d77
Avoid sysfs oops when an rc_dev's raw device is absent

commit 720bb6436ff30fccad05cf5bdf961ea5b1f5686d upstream.

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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/media/rc/rc-main.c