lttng lib: ring buffer move null pointer check to open
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Dec 2011 14:26:52 +0000 (09:26 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Dec 2011 14:26:52 +0000 (09:26 -0500)
Let's move the NULL buf check to the file "open", where it belongs.  The
"open" file operation is the actual interface between lib ring buffer
and the modules using it.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/ring_buffer_mmap.c
lib/ringbuffer/ring_buffer_vfs.c

index cf374348d907334f81e3f2d9b67ef8bce44789d2..c9d6e89a76955fbf0f062413e1c6fba1feb98df5 100644 (file)
@@ -80,9 +80,6 @@ static int lib_ring_buffer_mmap_buf(struct lib_ring_buffer *buf,
        if (config->output != RING_BUFFER_MMAP)
                return -EINVAL;
 
-       if (!buf)
-               return -EBADF;
-
        mmap_buf_len = chan->backend.buf_size;
        if (chan->backend.extra_reader_sb)
                mmap_buf_len += chan->backend.subbuf_size;
index 1708ffd6bc9b1b80f06da11af5cb7830c2a6923b..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;
This page took 0.026133 seconds and 4 git commands to generate.