summaryrefslogtreecommitdiffstats
path: root/kernel/relay.c
diff options
context:
space:
mode:
authorTom Zanussi <zanussi@us.ibm.com>2007-07-12 08:12:04 +0200
committerJens Axboe <jens.axboe@oracle.com>2007-07-13 14:14:26 +0200
commit24da24de2eae0c277b85836e2b4b09cfafeea995 (patch)
treec7025d1fd59c116584e166d8e2c7e455718fd056 /kernel/relay.c
parent773208946a132fb733ba273ee8562814f828cc28 (diff)
downloadlinux-24da24de2eae0c277b85836e2b4b09cfafeea995.tar.gz
linux-24da24de2eae0c277b85836e2b4b09cfafeea995.tar.bz2
linux-24da24de2eae0c277b85836e2b4b09cfafeea995.zip
relay: fix bogus cast in subbuf_splice_actor()
The current code that sets the read position in subbuf_splice_actor may give erroneous results if the buffer size isn't a power of 2. This patch fixes the problem. Signed-off-by: Tom Zanussi <zanussi@us.ibm.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'kernel/relay.c')
-rw-r--r--kernel/relay.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/relay.c b/kernel/relay.c
index 3b299fb3855c..780269765f25 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1074,7 +1074,9 @@ static int subbuf_splice_actor(struct file *in,
unsigned int pidx, poff, total_len, subbuf_pages, ret;
struct rchan_buf *rbuf = in->private_data;
unsigned int subbuf_size = rbuf->chan->subbuf_size;
- size_t read_start = ((size_t)*ppos) % rbuf->chan->alloc_size;
+ uint64_t pos = (uint64_t) *ppos;
+ uint32_t alloc_size = (uint32_t) rbuf->chan->alloc_size;
+ size_t read_start = (size_t) do_div(pos, alloc_size);
size_t read_subbuf = read_start / subbuf_size;
size_t padding = rbuf->padding[read_subbuf];
size_t nonpad_end = read_subbuf * subbuf_size + subbuf_size - padding;