Skip to content

Commit 106f41f

Browse files
committed
tracing: Have the histogram compare functions convert to u64 first
The compare functions of the histogram code would be specific for the size of the value being compared (byte, short, int, long long). It would reference the value from the array via the type of the compare, but the value was stored in a 64 bit number. This is fine for little endian machines, but for big endian machines, it would end up comparing zeros or all ones (depending on the sign) for anything but 64 bit numbers. To fix this, first derference the value as a u64 then convert it to the type being compared. Link: http://lkml.kernel.org/r/[email protected] Cc: [email protected] Fixes: 08d43a5 ("tracing: Add lock-free tracing_map") Acked-by: Tom Zanussi <[email protected]> Reported-by: Sven Schnelle <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 79e65c2 commit 106f41f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/trace/tracing_map.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ static int tracing_map_cmp_atomic64(void *val_a, void *val_b)
148148
#define DEFINE_TRACING_MAP_CMP_FN(type) \
149149
static int tracing_map_cmp_##type(void *val_a, void *val_b) \
150150
{ \
151-
type a = *(type *)val_a; \
152-
type b = *(type *)val_b; \
151+
type a = (type)(*(u64 *)val_a); \
152+
type b = (type)(*(u64 *)val_b); \
153153
\
154154
return (a > b) ? 1 : ((a < b) ? -1 : 0); \
155155
}

0 commit comments

Comments
 (0)