]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - drivers/media/rc/lirc_dev.c
Merge tag 'media/v4.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[mirror_ubuntu-hirsute-kernel.git] / drivers / media / rc / lirc_dev.c
index 3854809e853110ea74867d5ecda8f08acb3609b6..a54ca531d8ef85280c8cf9df7b7b19ac226f7032 100644 (file)
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -472,7 +468,7 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file)
                if (retval) {
                        module_put(cdev->owner);
                        ir->open--;
-               } else {
+               } else if (ir->buf) {
                        lirc_buffer_clear(ir->buf);
                }
                if (ir->task)
@@ -582,7 +578,7 @@ long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                result = put_user(ir->d.features, (__u32 __user *)arg);
                break;
        case LIRC_GET_REC_MODE:
-               if (LIRC_CAN_REC(ir->d.features)) {
+               if (!LIRC_CAN_REC(ir->d.features)) {
                        result = -ENOTTY;
                        break;
                }
@@ -592,7 +588,7 @@ long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                                  (__u32 __user *)arg);
                break;
        case LIRC_SET_REC_MODE:
-               if (LIRC_CAN_REC(ir->d.features)) {
+               if (!LIRC_CAN_REC(ir->d.features)) {
                        result = -ENOTTY;
                        break;
                }
@@ -651,6 +647,9 @@ ssize_t lirc_dev_fop_read(struct file *file,
                return -ENODEV;
        }
 
+       if (!LIRC_CAN_REC(ir->d.features))
+               return -EINVAL;
+
        dev_dbg(ir->d.dev, LOGHEAD "read called\n", ir->d.name, ir->d.minor);
 
        buf = kzalloc(ir->chunk_size, GFP_KERNEL);