mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
relay: check array offset before using it
Smatch complains that we started using the array offset before we
checked that it was valid.
Fixes: 017c59c042
('relay: Use per CPU constructs for the relay channel buffer pointers')
Link: http://lkml.kernel.org/r/20161013084947.GC16198@mwanda
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
bd4171a5d4
commit
9a29d0fbc2
@@ -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)
|
||||||
|
Reference in New Issue
Block a user