--- zzzz-none-000/linux-3.10.107/drivers/media/rc/lirc_dev.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/rc/lirc_dev.c 2021-02-04 17:41:59.000000000 +0000 @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -467,6 +468,12 @@ goto error; } + if (ir->d.rdev) { + retval = rc_open(ir->d.rdev); + if (retval) + goto error; + } + cdev = ir->cdev; if (try_module_get(cdev->owner)) { ir->open++; @@ -511,6 +518,8 @@ WARN_ON(mutex_lock_killable(&lirc_dev_lock)); + rc_close(ir->d.rdev); + ir->open--; if (ir->attached) { ir->d.set_use_dec(ir->d.data); @@ -544,14 +553,14 @@ if (!ir->attached) return POLLERR; - poll_wait(file, &ir->buf->wait_poll, wait); + if (ir->buf) { + poll_wait(file, &ir->buf->wait_poll, wait); - if (ir->buf) if (lirc_buffer_empty(ir->buf)) ret = 0; else ret = POLLIN | POLLRDNORM; - else + } else ret = POLLERR; dev_dbg(ir->d.dev, LOGHEAD "poll result = %d\n", @@ -585,7 +594,7 @@ switch (cmd) { case LIRC_GET_FEATURES: - result = put_user(ir->d.features, (__u32 *)arg); + result = put_user(ir->d.features, (__u32 __user *)arg); break; case LIRC_GET_REC_MODE: if (!(ir->d.features & LIRC_CAN_REC_MASK)) { @@ -595,7 +604,7 @@ result = put_user(LIRC_REC2MODE (ir->d.features & LIRC_CAN_REC_MASK), - (__u32 *)arg); + (__u32 __user *)arg); break; case LIRC_SET_REC_MODE: if (!(ir->d.features & LIRC_CAN_REC_MASK)) { @@ -603,7 +612,7 @@ break; } - result = get_user(mode, (__u32 *)arg); + result = get_user(mode, (__u32 __user *)arg); if (!result && !(LIRC_MODE2REC(mode) & ir->d.features)) result = -EINVAL; /* @@ -612,7 +621,7 @@ */ break; case LIRC_GET_LENGTH: - result = put_user(ir->d.code_length, (__u32 *)arg); + result = put_user(ir->d.code_length, (__u32 __user *)arg); break; case LIRC_GET_MIN_TIMEOUT: if (!(ir->d.features & LIRC_CAN_SET_REC_TIMEOUT) || @@ -621,7 +630,7 @@ break; } - result = put_user(ir->d.min_timeout, (__u32 *)arg); + result = put_user(ir->d.min_timeout, (__u32 __user *)arg); break; case LIRC_GET_MAX_TIMEOUT: if (!(ir->d.features & LIRC_CAN_SET_REC_TIMEOUT) || @@ -630,7 +639,7 @@ break; } - result = put_user(ir->d.max_timeout, (__u32 *)arg); + result = put_user(ir->d.max_timeout, (__u32 __user *)arg); break; default: result = -EINVAL; @@ -726,7 +735,7 @@ } } else { lirc_buffer_read(ir->buf, buf); - ret = copy_to_user((void *)buffer+written, buf, + ret = copy_to_user((void __user *)buffer+written, buf, ir->buf->chunk_size); if (!ret) written += ir->buf->chunk_size;