From: Mathieu Desnoyers Date: Wed, 30 Nov 2011 18:34:16 +0000 (-0500) Subject: lttng lib: ring buffer move null pointer check to open X-Git-Tag: v3.3-rc1~152^2~101^2~112 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eeb34e2113576aea782094d1e30f22b445355fe8;p=pandora-kernel.git lttng lib: ring buffer move null pointer check to open * Dan Carpenter wrote: > The patch c844b2f5cfea: "lttng lib: ring buffer" from Nov 28, 2011, > leads to the following Smatch complaint: > > drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c +86 > +lib_ring_buffer_mmap_buf() > warn: variable dereferenced before check 'buf' (see line 79) > > drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c > 78 unsigned long length = vma->vm_end - vma->vm_start; > 79 struct channel *chan = buf->backend.chan; > ^^^^^^^^^^^^^^^^^ > Dereference. > > 80 const struct lib_ring_buffer_config *config = chan->backend.config; > 81 unsigned long mmap_buf_len; > 82 > 83 if (config->output != RING_BUFFER_MMAP) > 84 return -EINVAL; > 85 > 86 if (!buf) > ^^^^ > Check. > > 87 return -EBADF; > 88 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 Signed-off-by: Greg Kroah-Hartman --- Reading git-diff-tree failed