[media] lirc_dev: avoid potential null-dereference
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Wed, 7 Jan 2015 01:53:37 +0000 (22:53 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 3 Feb 2015 19:33:42 +0000 (17:33 -0200)
We have to check pointer for NULL and then dereference it.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/rc/lirc_dev.c

index 1e0545a679599360f523c651a7fcddad7720862f..4de0e85af805b8b2086aa6191cfce4b9e4c12aab 100644 (file)
@@ -553,14 +553,14 @@ unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait)
        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",