Skip to contentSkip to conversation

lirc_dev: avoid potential null-dereference

git:media_tree/master Andy Shevchenko 1 participant 1 message Feb 3, 2015 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · Mauro Carvalho Chehab

This is an automatic generated email to let you know that the following patch were queued at the
http://git.linuxtv.org/cgit.cgi/media_tree.git tree:

Subject: [media] lirc_dev: avoid potential null-dereference
Author:  Andy Shevchenko <[email protected]>
Date:    Tue Jan 6 22:53:37 2015 -0300

We have to check pointer for NULL and then dereference it.

Sorry, seems I forgot to write that it is non-needed fix. Regarding to the current poll_wait() implementation and that fact that wait_poll is a first member of the struct lirc_buffer there is no dereference.

Quoted 33 lines
 drivers/media/rc/lirc_dev.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/media_tree.git/commit/?id=3656cddd50018d562d2df87c4698783898732914

drivers/media/rc/lirc_dev.c +3 -3
index 1e0545a..4de0e85 100644
@@ -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",
Signature · 2 lines
With Best Regards,
Andy Shevchenko