mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
relay: fix for possible loss/corruption of produced subbufs
Fix possible loss/corruption of produced subbufs in relay_subbufs_consumed(). When buf->subbufs_produced wraps around after UINT_MAX and buf->subbufs_consumed is still < UINT_MAX, the condition if (buf->subbufs_consumed > buf->subbufs_produced) will be true even for certain valid values of subbufs_consumed. This may lead to loss or corruption of produced subbufs. Signed-off-by: Aravind Srinivasan <raa.aars@gmail.com> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Tom Zanussi <zanussi@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
edb79a2132
commit
2c53d9109f
1 changed files with 5 additions and 3 deletions
|
@ -797,13 +797,15 @@ void relay_subbufs_consumed(struct rchan *chan,
|
||||||
if (!chan)
|
if (!chan)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cpu >= NR_CPUS || !chan->buf[cpu])
|
if (cpu >= NR_CPUS || !chan->buf[cpu] ||
|
||||||
|
subbufs_consumed > chan->n_subbufs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
buf = chan->buf[cpu];
|
buf = chan->buf[cpu];
|
||||||
buf->subbufs_consumed += subbufs_consumed;
|
if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed)
|
||||||
if (buf->subbufs_consumed > buf->subbufs_produced)
|
|
||||||
buf->subbufs_consumed = buf->subbufs_produced;
|
buf->subbufs_consumed = buf->subbufs_produced;
|
||||||
|
else
|
||||||
|
buf->subbufs_consumed += subbufs_consumed;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(relay_subbufs_consumed);
|
EXPORT_SYMBOL_GPL(relay_subbufs_consumed);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue