From: Mathieu Desnoyers Date: Fri, 9 Dec 2011 14:26:52 +0000 (-0500) Subject: lttng lib: ring buffer move null pointer check to open X-Git-Tag: v2.0-pre11~3 X-Git-Url: https://git.liburcu.org/?a=commitdiff_plain;h=733ce41dc418c2b7ea1c8c6d569f7951836b29f8;p=lttng-modules.git lttng lib: ring buffer move null pointer check to open 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 Signed-off-by: Mathieu Desnoyers --- diff --git a/lib/ringbuffer/ring_buffer_mmap.c b/lib/ringbuffer/ring_buffer_mmap.c index cf374348..c9d6e89a 100644 --- a/lib/ringbuffer/ring_buffer_mmap.c +++ b/lib/ringbuffer/ring_buffer_mmap.c @@ -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; diff --git a/lib/ringbuffer/ring_buffer_vfs.c b/lib/ringbuffer/ring_buffer_vfs.c index 1708ffd6..8b783052 100644 --- a/lib/ringbuffer/ring_buffer_vfs.c +++ b/lib/ringbuffer/ring_buffer_vfs.c @@ -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;