From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35A6063B8 for ; Mon, 20 Feb 2023 13:41:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B15A5C433EF; Mon, 20 Feb 2023 13:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676900482; bh=wkoPyxKt6DXotv4X9bXJr15HY2B8eSdYA+vfj3db58g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XrJO2Cn064oog6pAfpCfIGO6m+IuoZXb+6UL+uNAqQ3MXU8AdJ87QZSHNOQ4wa2Nm HvoysSqzq7OfZOx0VbdUW7Rstzp7fOcs9R1g+ujWT7bL03PsD7kLWrqprillDEZf2D LOIxWWsJY6JM5aIPjG3B7xuTNjL64DBCa2qWFAPc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Rafael J. Wysocki" Subject: [PATCH 4.19 41/89] thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type() Date: Mon, 20 Feb 2023 14:35:40 +0100 Message-Id: <20230220133554.583501168@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230220133553.066768704@linuxfoundation.org> References: <20230220133553.066768704@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Rafael J. Wysocki commit acd7e9ee57c880b99671dd99680cb707b7b5b0ee upstream. In order to prevent int340x_thermal_get_trip_type() from possibly racing with int340x_thermal_read_trips() invoked by int3403_notify() add locking to it in analogy with int340x_thermal_get_trip_temp(). Fixes: 6757a7abe47b ("thermal: intel: int340x: Protect trip temperature from concurrent updates") Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/thermal/int340x_thermal/int340x_thermal_zone.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c @@ -89,11 +89,13 @@ static int int340x_thermal_get_trip_type enum thermal_trip_type *type) { struct int34x_thermal_zone *d = zone->devdata; - int i; + int i, ret = 0; if (d->override_ops && d->override_ops->get_trip_type) return d->override_ops->get_trip_type(zone, trip, type); + mutex_lock(&d->trip_mutex); + if (trip < d->aux_trip_nr) *type = THERMAL_TRIP_PASSIVE; else if (trip == d->crt_trip_id) @@ -111,10 +113,12 @@ static int int340x_thermal_get_trip_type } } if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT) - return -EINVAL; + ret = -EINVAL; } - return 0; + mutex_unlock(&d->trip_mutex); + + return ret; } static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,