From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64636C43381 for ; Fri, 22 Mar 2019 11:35:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32C1321916 for ; Fri, 22 Mar 2019 11:35:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553254526; bh=kgCKib8OhUej0skCLzfVsQB7g0WJSGcIp5ETzAb4gII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cnINLDgGdsabLrQ2MxzIYCQegEHnqSV969lhrZjPXugxUQFPa79wPoGZFNfQwpmlU JKKaiFS/bUpwMGl4P64GkhAbBwjff8MyQp5IisXPFUHk8Yn5sj4A+8KSAC7Oef9SRM 3/6jofkT1UhEpOZmNva2HKWRN00MTDO2C3ckFVIA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730563AbfCVLfY (ORCPT ); Fri, 22 Mar 2019 07:35:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:36180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730365AbfCVLfW (ORCPT ); Fri, 22 Mar 2019 07:35:22 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BD17E2183E; Fri, 22 Mar 2019 11:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553254521; bh=kgCKib8OhUej0skCLzfVsQB7g0WJSGcIp5ETzAb4gII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bI9qLqOT12GTYkWLphCYznl2I1k6xyhhANdOlryzrYM96gLhJ6uyLm5d6AxYN6Iq+ +l8rPAjyGDGck2gGNbrLK1ciISeIBRn1n0Ng4qk7uYISlZOHKuB+gAM41FDn3BAT15 xAjnp4L24Ea+SGBwKHfQLkLxyFtdxIVelCbT9Dwo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhi Jin , Alexander Shishkin Subject: [PATCH 4.4 153/230] stm class: Fix an endless loop in channel allocation Date: Fri, 22 Mar 2019 12:14:51 +0100 Message-Id: <20190322111247.408624115@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111236.796964179@linuxfoundation.org> References: <20190322111236.796964179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhi Jin commit a1d75dad3a2c689e70a1c4e0214cca9de741d0aa 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: Zhi Jin Signed-off-by: Alexander Shishkin Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices") CC: stable@vger.kernel.org # v4.4+ Signed-off-by: Greg Kroah-Hartman --- drivers/hwtracing/stm/core.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/hwtracing/stm/core.c +++ b/drivers/hwtracing/stm/core.c @@ -229,6 +229,9 @@ static int find_free_channels(unsigned l ; if (i == width) return pos; + + /* step over [pos..pos+i) to continue search */ + pos += i; } return -1;