powerpc/perf/hv-24x7: Properly iterate through results
authorThiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Thu, 29 Jun 2017 21:55:33 +0000 (18:55 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 2 Jul 2017 10:40:30 +0000 (20:40 +1000)
commit41f577eb012f33d9af9c9fcee6a68a499562f875
tree7e32d574bd59169a6daabd5d3e5a93ebad36f9b7
parent36c8fb2c616d9373758b155d9723774353067a87
powerpc/perf/hv-24x7: Properly iterate through results

hv-24x7.h has a comment mentioning that result_buffer->results can't be
indexed as a normal array because it may contain results of variable sizes,
so fix the loop in h_24x7_event_commit_txn to take the variation into
account when iterating through results.

Another problem in that loop is that it sets h24x7hw->events[i] to NULL.
This assumes that only the i'th result maps to the i'th request, but that
is not guaranteed to be true. We need to leave the event in the array so
that we don't dereference a NULL pointer in case more than one result maps
to one request.

We still assume that each result has only one result element, so warn if
that assumption is violated.

Reviewed-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/perf/hv-24x7.c