Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e5fa4c6 authored by Andi Shyti's avatar Andi Shyti Committed by Mauro Carvalho Chehab
Browse files

[media] lirc_dev: fix potential segfault



When opening or closing a lirc character device, the framework
provides to the user the possibility to keep track of opening or
closing of the device by calling two functions:

 - set_use_inc() when opening the device
 - set_use_dec() when closing the device

if those are not set by the lirc user, the system segfaults.
Check the pointer value before calling the above functions.

Signed-off-by: default avatarAndi Shyti <andi.shyti@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 62e92682
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -411,7 +411,10 @@ int lirc_unregister_driver(int minor)
			ir->d.name, ir->d.minor);
		wake_up_interruptible(&ir->buf->wait_poll);
		mutex_lock(&ir->irctl_lock);

		if (ir->d.set_use_dec)
			ir->d.set_use_dec(ir->d.data);

		module_put(cdev->owner);
		mutex_unlock(&ir->irctl_lock);
	} else {
@@ -469,6 +472,7 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file)
	cdev = ir->cdev;
	if (try_module_get(cdev->owner)) {
		ir->open++;
		if (ir->d.set_use_inc)
			retval = ir->d.set_use_inc(ir->d.data);

		if (retval) {
@@ -510,6 +514,7 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)

	ir->open--;
	if (ir->attached) {
		if (ir->d.set_use_dec)
			ir->d.set_use_dec(ir->d.data);
		module_put(cdev->owner);
	} else {