Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp394887pxj; Thu, 20 May 2021 11:48:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxKYJQ35dOVF1VE71ghg0prrMQAkGrkjLaRSGblJoA0mPgavqzQ4mDg9uWmLQ2y+ce5WfT X-Received: by 2002:a17:906:8504:: with SMTP id i4mr6207717ejx.515.1621536504531; Thu, 20 May 2021 11:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621536504; cv=none; d=google.com; s=arc-20160816; b=l4Xsk1yul7XiR9yLR2TV09PAxOo7tNlLUe4p6zMjIap3z9Bay7lE3T3lEH/YLsZmFO TxKt+Fhis93ThFYHs7OYaQvOkxHD08ehKhpe7YKpNflmfm2Z7c+h5lSlNXbmsz5RhDH2 D1SbqicW1Z+6GzYI2EYcqjftqDlHmoP9bDNRNbYx/buJMkvDuoUuo139n2Z1c3p1iVud irJfduOj1tPAK+QR9IbUC8TTZrPQ4k+30u5TerHGIWDqZuJs5bffU6one6J3gphIxISO Wikxry6LwgWLz1QA5tCkHINi0qieIvSc7HkzlXX1JwO8MNqyXt+y7kEOf41AYb8/ixYE 6lXA== 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=22OtFEKTjp8IjqzLXxhXZSViTvBoeIads/ux0WcxLfA=; b=zGZUwOHlmNppcW/a0s2q0DxTsylOOYXDncofAMyGY1SKsyGS6100QDCIBP0xbyp6Vo PFjoEeP4vvYyXtm4yArmZgcgXSJuAirnEZtiiMsTu0VemRc7eaakonk53wItXqKHsBC9 Hqkz+xOCHICUvVbpe6piYJImeBf3DD3YlujbqGtinJIDaNO5XTgdBPcBNhcNKzrzpWL9 hL3oHP2g7VAfoXQlbqWoAewTPXQb0aEUs1LPQDv67i92TEU8bMzBt/WVQuc/cCx3oVWi FmVgMvWemBLpOc27WpPPJRSCONDyH1g96KmZ8pA4b+5+Rz6I01UyKmv9A3uRfDP1Nt+4 hrCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p0eIehOJ; 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 j8si4008934ejk.38.2021.05.20.11.48.00; Thu, 20 May 2021 11:48:24 -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=p0eIehOJ; 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 S236081AbhETKVz (ORCPT + 99 others); Thu, 20 May 2021 06:21:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:42434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235079AbhETKLM (ORCPT ); Thu, 20 May 2021 06:11:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11FD761964; Thu, 20 May 2021 09:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503809; bh=8ECmGFAofV+bbpLcSvZSp8ySpsLfNcKRbrYCBBB0ZdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0eIehOJ9Hetu7DVH9siRR5gmRpXWNhyTzlvVb13F4AS5VU1h8tmA4ttWdsFBaF6B 0qgbd9vFccdoDkhxL/Du4j8XMkVlaJ742GF8p8h56n6VbxIm3gYJly6HqrpbrqW1T4 rDR1BFNZJwh3Frc0YRBgTLNG/wFU0zwew7lUAm+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukasz Luba , Daniel Lezcano Subject: [PATCH 4.19 389/425] thermal/core/fair share: Lock the thermal zone while looping over instances Date: Thu, 20 May 2021 11:22:38 +0200 Message-Id: <20210520092144.187009095@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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/fair_share.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/thermal/fair_share.c +++ b/drivers/thermal/fair_share.c @@ -94,6 +94,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; @@ -122,6 +124,8 @@ static int fair_share_throttle(struct th mutex_unlock(&instance->cdev->lock); thermal_cdev_update(cdev); } + + mutex_unlock(&tz->lock); return 0; }