]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.177/stm-class-fix-an-endless-loop-in-channel-allocation.patch
Linux 4.4.177
[thirdparty/kernel/stable-queue.git] / releases / 4.4.177 / stm-class-fix-an-endless-loop-in-channel-allocation.patch
CommitLineData
5e5f3238
GKH
1From a1d75dad3a2c689e70a1c4e0214cca9de741d0aa Mon Sep 17 00:00:00 2001
2From: Zhi Jin <zhi.jin@intel.com>
3Date: Thu, 6 Sep 2018 15:22:10 +0800
4Subject: stm class: Fix an endless loop in channel allocation
5
6From: Zhi Jin <zhi.jin@intel.com>
7
8commit a1d75dad3a2c689e70a1c4e0214cca9de741d0aa upstream.
9
10There is a bug in the channel allocation logic that leads to an endless
11loop when looking for a contiguous range of channels in a range with a
12mixture of free and occupied channels. For example, opening three
13consequtive channels, closing the first two and requesting 4 channels in
14a row will trigger this soft lockup. The bug is that the search loop
15forgets to skip over the range once it detects that one channel in that
16range is occupied.
17
18Restore the original intent to the logic by fixing the omission.
19
20Signed-off-by: Zhi Jin <zhi.jin@intel.com>
21Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
22Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices")
23CC: stable@vger.kernel.org # v4.4+
24Signed-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;