diff options
author | Sean Young <sean@mess.org> | 2017-09-23 17:44:03 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-14 10:35:19 -0500 |
commit | cb84343fced1febb5b21a9ef9082a07bfc3e7427 (patch) | |
tree | 769f5c01f820e7eac7ecde2c01ff954f0f78a9bc /drivers/media/rc | |
parent | 7790e81f7e1f7f122f8fcccd91443a2571421aba (diff) | |
download | op-kernel-dev-cb84343fced1febb5b21a9ef9082a07bfc3e7427.zip op-kernel-dev-cb84343fced1febb5b21a9ef9082a07bfc3e7427.tar.gz |
media: lirc: do not call close() or open() on unregistered devices
If a lirc chardev is held open after a device is unplugged, rc_close()
will be called after rc_unregister_device(). The driver is not expecting
any calls at this point, and the iguanair driver causes an oops in
this scenario.
rc_open() can be called when the device is removed too, by calling open
on the chardev whilst the device is being removed.
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r-- | drivers/media/rc/rc-main.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 8b1b20e..ace00e7 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -863,11 +863,15 @@ int rc_open(struct rc_dev *rdev) mutex_lock(&rdev->lock); - if (!rdev->users++ && rdev->open != NULL) - rval = rdev->open(rdev); + if (!rdev->registered) { + rval = -ENODEV; + } else { + if (!rdev->users++ && rdev->open) + rval = rdev->open(rdev); - if (rval) - rdev->users--; + if (rval) + rdev->users--; + } mutex_unlock(&rdev->lock); @@ -886,7 +890,7 @@ void rc_close(struct rc_dev *rdev) if (rdev) { mutex_lock(&rdev->lock); - if (!--rdev->users && rdev->close != NULL) + if (!--rdev->users && rdev->close && rdev->registered) rdev->close(rdev); mutex_unlock(&rdev->lock); |