Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp687006pxv; Thu, 22 Jul 2021 09:43:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5ZdCTn+/LTuFazkIJhgduIe+uvDAZfnhEKQJ9Knwm3gDlNMmLT6ef6Mzl7Oi56mtjYt6j X-Received: by 2002:a5e:9917:: with SMTP id t23mr494867ioj.158.1626972239237; Thu, 22 Jul 2021 09:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972239; cv=none; d=google.com; s=arc-20160816; b=qlk6CCIeKSy1w6JZdKwcs0NYesMkpo1x+CfhW6LfGRgWSHgauWebya3+kx7bx8G3Xu 7Bc/8qBwUyTu8iIBwmvnSIh4+BUsUIKJDBsf6yJza2X+8HwzK0VfBHRD9dU4Do3c/4ea 48383WGA4nS8v8YUJnueTJPcrnyEEo2ZLtFHO7xI0dOiQeEv0zCxlKYpr5gj3N9AZ5+r wQiV0v8MA8Z4T8s+oIGn3nVA3fwgGVti7T8kgLE6+ZD32/ukEfFsAlLRBbExI+0vhMAX 0uatoVrS/yV0LdrRsKLJGvHf0fbr76kCtA6Dffg0sWG5nbwshZ9czsmQApG1OccaNENW duFA== 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=XR5NEw7LEcyV4RcsnuXvBpknaYbQAdDIQKqMV3/CHug=; b=W2nEuBj+iTZyWOQeGcSMfblKER0umY+RVUN2jvNi4kjq7M7dnvvqYSb3w2o0X1Bh3o 1SWMkC9w8RnRK3/owPxGc7JrTeD96CMXELRndJYAPQxjYuyXM+DV1nCyS7sq3iC/EuBE 7tVhm26TWD9xsgSiIoaIPENMR1kEDKJlwxpbg1vgAjhhIev+S52+QLPcv/zILCyogcKP S/56xX0ReqJfrML/ClVj+QllO13Z+GuI6y2f/zjKK4xGpqX9zW9NS5cKd6Mlu8wposNp /4hmn0ThIk9a/35lG/FFIcl0OmH7ECWlRFb6QXZDacNwvS1rzb/+KzRpqG36KEpkEEDy SZhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GIfHnErx; 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 t9si32261411jaj.20.2021.07.22.09.43.42; Thu, 22 Jul 2021 09:43:59 -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=GIfHnErx; 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 S233032AbhGVQCY (ORCPT + 99 others); Thu, 22 Jul 2021 12:02:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:35130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233395AbhGVP6w (ORCPT ); Thu, 22 Jul 2021 11:58:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F835613BC; Thu, 22 Jul 2021 16:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626971963; bh=FQXIRt4S9fKQcn3FknQpuVukK2IJVmAwxwDQPkJ1EHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GIfHnErxXL7F4uRA2YxKy3DQVge6rwhl/ZwcFfHTT88VOaRkQL+eKUlspfamCdffW owq/+p2vLdJsNrTtTDUHHC39+AAculmVtlTxS3+AOYO8yXEcWWP0PxKeE7t8io97pa 2J4nUUi53tcs6KtTVscLudqABEaR7LMblY+nVW38= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Daniel Lezcano , Sasha Levin Subject: [PATCH 5.10 077/125] thermal/core/thermal_of: Stop zone device before unregistering it Date: Thu, 22 Jul 2021 18:31:08 +0200 Message-Id: <20210722155627.243953800@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155624.672583740@linuxfoundation.org> References: <20210722155624.672583740@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: Dmitry Osipenko [ Upstream commit 5e5c9f9a75fc4532980c2e699caf8a36070a3a2e ] Zone device is enabled after thermal_zone_of_sensor_register() completion, but it's not disabled before senor is unregistered, leaving temperature polling active. This results in accessing a disabled zone device and produces a warning about this problem. Stop zone device before unregistering it in order to fix this "use-after-free" problem. Signed-off-by: Dmitry Osipenko Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20210616190417.32214-3-digetx@gmail.com Signed-off-by: Sasha Levin --- drivers/thermal/thermal_of.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 5b76f9a1280d..6379f26a335f 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -559,6 +559,9 @@ void thermal_zone_of_sensor_unregister(struct device *dev, if (!tz) return; + /* stop temperature polling */ + thermal_zone_device_disable(tzd); + mutex_lock(&tzd->lock); tzd->ops->get_temp = NULL; tzd->ops->get_trend = NULL; -- 2.30.2