Commit cb84343f authored by Sean Young's avatar Sean Young Committed by Mauro Carvalho Chehab
Browse files

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: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 7790e81f
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -863,11 +863,15 @@ int rc_open(struct rc_dev *rdev)


	mutex_lock(&rdev->lock);
	mutex_lock(&rdev->lock);


	if (!rdev->users++ && rdev->open != NULL)
	if (!rdev->registered) {
		rval = -ENODEV;
	} else {
		if (!rdev->users++ && rdev->open)
			rval = rdev->open(rdev);
			rval = rdev->open(rdev);


		if (rval)
		if (rval)
			rdev->users--;
			rdev->users--;
	}


	mutex_unlock(&rdev->lock);
	mutex_unlock(&rdev->lock);


@@ -886,7 +890,7 @@ void rc_close(struct rc_dev *rdev)
	if (rdev) {
	if (rdev) {
		mutex_lock(&rdev->lock);
		mutex_lock(&rdev->lock);


		if (!--rdev->users && rdev->close != NULL)
		if (!--rdev->users && rdev->close && rdev->registered)
			rdev->close(rdev);
			rdev->close(rdev);


		mutex_unlock(&rdev->lock);
		mutex_unlock(&rdev->lock);