From 24da24de2eae0c277b85836e2b4b09cfafeea995 Mon Sep 17 00:00:00 2001 From: Tom Zanussi Date: Thu, 12 Jul 2007 08:12:04 +0200 Subject: 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 Signed-off-by: Jens Axboe --- kernel/relay.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'kernel/relay.c') diff --git a/kernel/relay.c b/kernel/relay.c index 3b299fb3855..780269765f2 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; -- cgit v1.2.3 From d3f35d98b3b87d2506289320375687c6e9bc53ed Mon Sep 17 00:00:00 2001 From: Tom Zanussi Date: Thu, 12 Jul 2007 08:12:05 +0200 Subject: relay: fixup kerneldoc comment Change comment from kerneldoc to normal. Signed-off-by: Tom Zanussi Signed-off-by: Jens Axboe --- kernel/relay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kernel/relay.c') diff --git a/kernel/relay.c b/kernel/relay.c index 780269765f2..a615a8f513f 100644 --- a/kernel/relay.c +++ b/kernel/relay.c @@ -1061,7 +1061,7 @@ static struct pipe_buf_operations relay_pipe_buf_ops = { .get = generic_pipe_buf_get, }; -/** +/* * subbuf_splice_actor - splice up to one subbuf's worth of data */ static int subbuf_splice_actor(struct file *in, -- cgit v1.2.3