Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp640051pxj; Thu, 20 May 2021 18:41:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygyU5NUP1WDB4oieBay4VbTDSlVY21HNXL5vPQrixDc4SllEL1S48ajXIlkAlu5cnopnOl X-Received: by 2002:aa7:d058:: with SMTP id n24mr8089610edo.275.1621561301609; Thu, 20 May 2021 18:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621561301; cv=none; d=google.com; s=arc-20160816; b=O2r496ghjjTdEESvPmRf3R9KTul3hiAesO/8k8Rv5c9nzrKLF0uwla+T2dgm+UdZAC BxNPD58hZErFz2co+TQprIHMwmna6Ld2LR+mvCl+Z+WUY4AABldD4t7jTrjsNUc1t2yG JGx7Mby/mY3Yh7w8xgEaoNqcCP3g9Yw6OdaSPNMNVgXv95ySyarYVAe2Pcr+Q8DsiTJw 806uUR0axqwh5HJx0lLdcmN/5uMvyL0z77Tat4jTpsJsy7PdcNGVaA0jejAnYySHRIzN dXBe0tpspk/UFyb9omSESVmI7RaA4mexMsEfGIJCmRLY0vrlnBWaXp443K/O01oaup8d Wsbg== 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=DCyU0diaOn28cOoYIwdXGDVPscSCosCTl8bMMKyTatc=; b=biHkjPUveWrqtODLUDn701eTD+KVYnNMmGLwv/D2GlfIGkbKPbQezgI/qiXqgD8nV2 rRGTzaV9n/p6XWwCWhpb+YAj5B+bnK3r28nllAEKzlsoGHLvTh1Vqcf/RRbvV/r5YRAb UEFKlH2WEE/6D2TDSdBC/dMe7AV953CQfutapE+3cFEEhgVRaAtC8OpY4gIiatS8S44e 80zy8RSOMxwlZaa7X5ojfHvZ/meP0Bc3OGVFZO+vEeBlnveJhMC1PFx8jIW5qWSEshD9 GRWginhB2KKdpnLf7AvYtIW1ifpg6RZgK2m8p2GpqtfpIiun7gHRAT17twv14r74imgp 4vTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nKh1rsIq; 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 y16si3479104edu.586.2021.05.20.18.41.17; Thu, 20 May 2021 18:41:41 -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=nKh1rsIq; 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 S241979AbhETLqu (ORCPT + 99 others); Thu, 20 May 2021 07:46:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:44022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241186AbhETLXK (ORCPT ); Thu, 20 May 2021 07:23:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91BA661964; Thu, 20 May 2021 10:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505525; bh=Ym1DpdQO5VB2aSbe9sWiUpyoIr1TKeJ0DVms1qB8QYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nKh1rsIquk8jb23jVURsyh9LCaiYNg7uNmyEFNFpDeJiF/2s83wbs0W8ifOn3W4jn a/goX5crkeoJ4CZ2YS9Etka1lE2F0noB00MVBAMDE5rS4tp538hlbVHSopuNeqNAiA bumZY3JNkjJbAqglX95MEvOS6Z1XuwOZs3qSc+98= 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.4 174/190] thermal/core/fair share: Lock the thermal zone while looping over instances Date: Thu, 20 May 2021 11:23:58 +0200 Message-Id: <20210520092107.924945062@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 @@ -93,6 +93,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; @@ -119,6 +121,8 @@ static int fair_share_throttle(struct th instance->cdev->updated = false; thermal_cdev_update(cdev); } + + mutex_unlock(&tz->lock); return 0; }