stm class: Fix channel bitmap on 32-bit systems
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Wed, 17 Apr 2019 07:35:35 +0000 (10:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 May 2019 16:23:24 +0000 (18:23 +0200)
commitd9ec75d048d74ae7805dfaae503ff16a29b88bda
treeaa20005a985d826e3d002f9133b84c6b109a694e
parent44bc4e8815a4037ef01b4a860ae5743a58dc3736
stm class: Fix channel bitmap on 32-bit systems

commit 51e0f227812ed81a368de54157ebe14396b4be03 upstream.

Commit 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace
Module devices") naively calculates the channel bitmap size in 64-bit
chunks regardless of the size of underlying unsigned long, making the
bitmap half as big on a 32-bit system. This leads to an out of bounds
access with the upper half of the bitmap.

Fix this by using BITS_TO_LONGS. While at it, convert to using
struct_size() for the total size calculation of the master struct.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices")
Reported-by: Mulu He <muluhe@codeaurora.org>
Cc: stable@vger.kernel.org # v4.4+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/stm/core.c