Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2490484pxj; Mon, 10 May 2021 04:22:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxng+i+e1zyrPwHQQsvy+04at3nIJpFnNAlwH0aDZA5HvD6yy19/jO+IDpZzP8qlF5su1Ex X-Received: by 2002:a92:c746:: with SMTP id y6mr21599269ilp.30.1620645724467; Mon, 10 May 2021 04:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645724; cv=none; d=google.com; s=arc-20160816; b=swx/XNChOFBsLfl7/S4Ul0S9BoAYkcGOcgpW5SFOlwaOpUiWohoUpzbaKnv9OoHalZ lMxH9kRfVXe8sP2g/i8kOuCgxIzYax3xAZW6/sRVACHiRqhjoKPE5UxERx6OHJFnh7Tn 9+DWJutJcIZspL1NZkECUujSM6tuXOwQzr9y7JBe1G1Ez5rpKfT72mWfHYcr211Dg1Ym uDIE2k3yeKDSVFaQ1N3w4qltxaHcRwCqRAREi9ginM+TMpScZ/xh96CLjioZg/4C0VB7 Q6g7d90qT1d6uGngKIJt5KgBFUcBNodmPK6pNUtpZPhNXPfr12uuMX8O7ugDNleoy73i cJig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6vfOyHod1WugOj0tI5iLBNWXRKHqJfk699+F2sghs+0=; b=zmREVtQSJZ2xfT7mDo1yG1H44v5XJcki/S+HHK35axW5JWDWmU9P5Oz58RNBrm2xf/ pLDqKCeKD4bl//kRd2vvHdE+5mBmTC3FlRoKnEKDBim1xCeWoC6NRMwJ0mRK5MCz8aTz kuvC5BR5gmFbydZaJnX8UPAXSxM2dwt0tqpIai/YqbZ+1bpmuQoZ4vv2J1wXkM7E6EQ/ LceDRTrUiZvwd+Z3OndVfdjxFa3tnhJjYAUKDdl2ZmNJn3azggCwyhXN/VieWE+g443E kSYrBRd0zQ9FYaKsi29tsK/J1pXZRpXtuNaiISuFLx4tbDTim6qXgeKLZa/5/U6ZyAPE jpGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MMOxQ5sC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si5093669ilx.117.2021.05.10.04.21.51; Mon, 10 May 2021 04:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MMOxQ5sC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235586AbhEJLTu (ORCPT + 99 others); Mon, 10 May 2021 07:19:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:46508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234003AbhEJKzo (ORCPT ); Mon, 10 May 2021 06:55:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D3D1961925; Mon, 10 May 2021 10:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643399; bh=pTjM3Nl2nmy8c77cRJ2FbBpx2W0g03c7lC80yDjpenU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMOxQ5sCIA391TmZaJcUhkoOkksCSoKMBR/bbuUVOhSX0wy7/+VN8Fdhsh+SQsorp BdDKsZZMAoWZMAlN0vgVsRDQQ6TshzqzE0XCQETSm3rWyoA1EYV1XKvIQxLE+M2pvx sKXyc6m98DWYv7RNF/OTrb636ySiOnd8eP23F9t4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukasz Luba , Daniel Lezcano Subject: [PATCH 5.10 299/299] thermal/core/fair share: Lock the thermal zone while looping over instances Date: Mon, 10 May 2021 12:21:36 +0200 Message-Id: <20210510102014.798993178@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukasz Luba commit fef05776eb02238dcad8d5514e666a42572c3f32 upstream. The tz->lock must be hold during the looping over the instances in that thermal zone. This lock was missing in the governor code since the beginning, so it's hard to point into a particular commit. CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Lukasz Luba Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20210422153624.6074-2-lukasz.luba@arm.com Signed-off-by: Greg Kroah-Hartman --- drivers/thermal/gov_fair_share.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -82,6 +82,8 @@ static int fair_share_throttle(struct th int total_instance = 0; int cur_trip_level = get_trip_level(tz); + mutex_lock(&tz->lock); + list_for_each_entry(instance, &tz->thermal_instances, tz_node) { if (instance->trip != trip) continue; @@ -110,6 +112,8 @@ static int fair_share_throttle(struct th mutex_unlock(&instance->cdev->lock); thermal_cdev_update(cdev); } + + mutex_unlock(&tz->lock); return 0; }