Commit 678e9688 authored by Zhi Jin's avatar Zhi Jin Committed by Kleber Sacilotto de Souza

stm class: Fix an endless loop in channel allocation

BugLink: https://bugs.launchpad.net/bugs/1822271

commit a1d75dad upstream.

There is a bug in the channel allocation logic that leads to an endless
loop when looking for a contiguous range of channels in a range with a
mixture of free and occupied channels. For example, opening three
consequtive channels, closing the first two and requesting 4 channels in
a row will trigger this soft lockup. The bug is that the search loop
forgets to skip over the range once it detects that one channel in that
range is occupied.

Restore the original intent to the logic by fixing the omission.
Signed-off-by: default avatarZhi Jin <zhi.jin@intel.com>
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 7bd1d409 ("stm class: Introduce an abstraction for System Trace Module devices")
CC: stable@vger.kernel.org # v4.4+
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarJuerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 5d612dbb
...@@ -229,6 +229,9 @@ static int find_free_channels(unsigned long *bitmap, unsigned int start, ...@@ -229,6 +229,9 @@ static int find_free_channels(unsigned long *bitmap, unsigned int start,
; ;
if (i == width) if (i == width)
return pos; return pos;
/* step over [pos..pos+i) to continue search */
pos += i;
} }
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment