]>
Commit | Line | Data |
---|---|---|
5e5f3238 GKH |
1 | From a1d75dad3a2c689e70a1c4e0214cca9de741d0aa Mon Sep 17 00:00:00 2001 |
2 | From: Zhi Jin <zhi.jin@intel.com> | |
3 | Date: Thu, 6 Sep 2018 15:22:10 +0800 | |
4 | Subject: stm class: Fix an endless loop in channel allocation | |
5 | ||
6 | From: Zhi Jin <zhi.jin@intel.com> | |
7 | ||
8 | commit a1d75dad3a2c689e70a1c4e0214cca9de741d0aa upstream. | |
9 | ||
10 | There is a bug in the channel allocation logic that leads to an endless | |
11 | loop when looking for a contiguous range of channels in a range with a | |
12 | mixture of free and occupied channels. For example, opening three | |
13 | consequtive channels, closing the first two and requesting 4 channels in | |
14 | a row will trigger this soft lockup. The bug is that the search loop | |
15 | forgets to skip over the range once it detects that one channel in that | |
16 | range is occupied. | |
17 | ||
18 | Restore the original intent to the logic by fixing the omission. | |
19 | ||
20 | Signed-off-by: Zhi Jin <zhi.jin@intel.com> | |
21 | Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> | |
22 | Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices") | |
23 | CC: stable@vger.kernel.org # v4.4+ | |
24 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
25 | ||
26 | --- | |
27 | drivers/hwtracing/stm/core.c | 3 +++ | |
28 | 1 file changed, 3 insertions(+) | |
29 | ||
30 | --- a/drivers/hwtracing/stm/core.c | |
31 | +++ b/drivers/hwtracing/stm/core.c | |
32 | @@ -229,6 +229,9 @@ static int find_free_channels(unsigned l | |
33 | ; | |
34 | if (i == width) | |
35 | return pos; | |
36 | + | |
37 | + /* step over [pos..pos+i) to continue search */ | |
38 | + pos += i; | |
39 | } | |
40 | ||
41 | return -1; |