lttng lib: ring buffer move null pointer check to open
[lttng-modules.git] / lib / ringbuffer / ring_buffer_vfs.c
index 9786d353cba185b696cddf61f7238bfea22443f7..8b783052a5f6cbe510e218120f6c16b56ebc96c5 100644 (file)
@@ -42,6 +42,9 @@ int lib_ring_buffer_open(struct inode *inode, struct file *file)
        struct lib_ring_buffer *buf = inode->i_private;
        int ret;
 
+       if (!buf)
+               return -EINVAL;
+
        ret = lib_ring_buffer_open_read(buf);
        if (ret)
                return ret;
@@ -245,6 +248,9 @@ long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd, unsigned long ar
                return put_ulong(buf->backend.array[sb_bindex]->mmap_offset,
                                 arg);
        }
+       case RING_BUFFER_FLUSH:
+               lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+               return 0;
        default:
                return -ENOIOCTLCMD;
        }
@@ -355,6 +361,9 @@ long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
                        return -EINVAL;
                return put_ulong(read_offset, arg);
        }
+       case RING_BUFFER_FLUSH:
+               lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+               return 0;
        default:
                return -ENOIOCTLCMD;
        }
@@ -362,6 +371,7 @@ long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
 #endif
 
 const struct file_operations lib_ring_buffer_file_operations = {
+       .owner = THIS_MODULE,
        .open = lib_ring_buffer_open,
        .release = lib_ring_buffer_release,
        .poll = lib_ring_buffer_poll,
This page took 0.023007 seconds and 4 git commands to generate.