perf: Fix off-by-one retval for write()
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 1 Aug 2017 15:48:32 +0000 (11:48 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 14 Aug 2017 21:02:19 +0000 (17:02 -0400)
kptr should only be advanced when we are reading the input.  We were
incrementing kptr for PERFMON_CMD_CPU_CAPS, resulting in returning '2' for
a write of '1'.

This managed to work for a while since we had another bug masking it, which
was fixed in commit 395ce5721d96 ("Fix Plan 9 partial write() return
values").

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/devarch.c

index b23d169..f9ac5c7 100644 (file)
@@ -445,7 +445,6 @@ static long arch_perf_write(struct perf_context *pc, const void *udata,
                        uint8_t *rptr;
                        struct perfmon_cpu_caps pcc;
 
-                       kptr++;
                        perfmon_get_cpu_caps(&pcc);
 
                        pc->resp_size = 6 * sizeof(uint32_t);