Commit 9a29d0fb authored by Dan Carpenter's avatar Dan Carpenter Committed by Linus Torvalds

relay: check array offset before using it

Smatch complains that we started using the array offset before we
checked that it was valid.

Fixes: 017c59c0 ('relay: Use per CPU constructs for the relay channel buffer pointers')
Link: 's avatarDan Carpenter <>
Signed-off-by: 's avatarAndrew Morton <>
Signed-off-by: 's avatarLinus Torvalds <>
parent bd4171a5
...@@ -809,11 +809,11 @@ void relay_subbufs_consumed(struct rchan *chan, ...@@ -809,11 +809,11 @@ void relay_subbufs_consumed(struct rchan *chan,
{ {
struct rchan_buf *buf; struct rchan_buf *buf;
if (!chan) if (!chan || cpu >= NR_CPUS)
return; return;
buf = *per_cpu_ptr(chan->buf, cpu); 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; return;
if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed) if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment