[media] lirc: cannot read from tx-only device
authorSean Young <sean@mess.org>
Wed, 1 Feb 2017 22:08:56 +0000 (20:08 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 3 Feb 2017 16:23:36 +0000 (14:23 -0200)
Bail out early, otherwise we follow a null pointer.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/rc/lirc_dev.c

index 0030ce0..a54ca53 100644 (file)
@@ -647,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);