From 32687886344b8740980b4d45f0b0b7b3bcd2599b Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 1 Feb 2017 20:08:56 -0200 Subject: [PATCH] UPSTREAM: [media] lirc: cannot read from tx-only device Bail out early, otherwise we follow a null pointer. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab (cherry picked from commit 32002f725fc708dccc6263b19b56fa3d91626be1) Signed-off-by: Ziyuan Xu --- drivers/media/rc/lirc_dev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 18b4daed8065..17d2723148b7 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -651,6 +651,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);