* [patch] relay: check array offset before using it
@ 2016-10-13 8:50 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2016-10-13 8:50 UTC (permalink / raw)
To: Andrew Morton, Akash Goel
Cc: Thomas Gleixner, Al Viro, Sebastian Andrzej Siewior,
Richard Weinberger, Zhouyi Zhou, Peter Zijlstra, linux-kernel,
kernel-janitors
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)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-10-13 8:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-13 8:50 [patch] relay: check array offset before using it Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox