From: Dan Carpenter <dan.carpenter@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Akash Goel <akash.goel@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Al Viro <viro@zeniv.linux.org.uk>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Richard Weinberger <richard@nod.at>,
Zhouyi Zhou <yizhouzhou@ict.ac.cn>,
Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] relay: check array offset before using it
Date: Thu, 13 Oct 2016 08:50:24 +0000 [thread overview]
Message-ID: <20161013084947.GC16198@mwanda> (raw)
Smatch complains that we started using the array offset before we
checked that it was valid.
Fixes: 017c59c042d0 ('relay: Use per CPU constructs for the relay channel buffer pointers')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/kernel/relay.c b/kernel/relay.c
index da79a10..8f18d31 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -809,11 +809,11 @@ void relay_subbufs_consumed(struct rchan *chan,
{
struct rchan_buf *buf;
- if (!chan)
+ if (!chan || cpu >= NR_CPUS)
return;
buf = *per_cpu_ptr(chan->buf, cpu);
- if (cpu >= NR_CPUS || !buf || subbufs_consumed > chan->n_subbufs)
+ if (!buf || subbufs_consumed > chan->n_subbufs)
return;
if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed)
reply other threads:[~2016-10-13 8:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161013084947.GC16198@mwanda \
--to=dan.carpenter@oracle.com \
--cc=akash.goel@intel.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=richard@nod.at \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=yizhouzhou@ict.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox