Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp694027pxv; Thu, 22 Jul 2021 09:52:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztVgGayXCiZ9huP/Pnmq9ZCpveGPIOVLDn+EVFqj7DuCZDYCSL88oVKFpSYUtMUM1gd0Pv X-Received: by 2002:a05:6602:24d8:: with SMTP id h24mr499825ioe.27.1626972763082; Thu, 22 Jul 2021 09:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972763; cv=none; d=google.com; s=arc-20160816; b=vw2B8K+6PrWNy8UdUYMPDzD9B+0aRD5If1I12BJgltP2qbcmi2FCaST7u4qRBSUHsK V2nqhHwkGWe5oto7i4xQmMhCoRNWVtfwuPqv+U73OauLF/JADpfVoaEUpImi0/ThRMFA JyBQdtDln8qQJag3kytRk956r/oEw2zMsd5Mk9TRGGUI3foD/v5pWUiIgNEo7mowWhO4 78MxOHMUfdkSapPrlkcjY8q+9g0lEhAcZ/T2ZM9vcM3l7DwSRl9bR+Xe/ia8T/GvojBk 8ha+vrs2z9e0VZPV4TTGV0ZqYMxZY1t3Jkj6dsEomSMApifzBXfjJ3EPpRbyJrGX9zZ4 uzdw== 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=Fix+8nBlgGD+SCVzAfjAul+Hiq0LvNTVplCTrVRF4iYuDs6BP4fH/0daxvPVC1mis8 tn3Cx7ArjCsAWs9Qos3R8AojJGZluYXkSj4SroFI5QXiUFhysMOyQzGAKpvO/ngP2v5B /K/unEDi3H/A1Xr6lNSJ3EuxwlR+MqhI3jhF9hHVBhUpAQc/Tq6KmkNGdEFGWwoSTple cpICVCd0VjPUflL9eetIpFm4ZCA7qEyJLt6GNPEcEKoGssica0ewgyX04hMiW6ljc+jR k3TOEKTA+634gm0punu9h4/4OKW+SpPN3OYKM4SgF9qFlVX3vPGxPK0sijWh5fWYlpmA 4S5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0m9nyMLD; 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 f12si12585914ilc.19.2021.07.22.09.52.31; Thu, 22 Jul 2021 09:52:43 -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=0m9nyMLD; 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 S234466AbhGVQK5 (ORCPT + 99 others); Thu, 22 Jul 2021 12:10:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:44264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234191AbhGVQF7 (ORCPT ); Thu, 22 Jul 2021 12:05:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DE0A061D2C; Thu, 22 Jul 2021 16:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626972393; bh=FQXIRt4S9fKQcn3FknQpuVukK2IJVmAwxwDQPkJ1EHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0m9nyMLDliC3HU2w2rH/ldod54S+CnO9zC5a1Dfq/c/tVuyjAh1K25RHuu0d3toQ0 fLUyefvoX/Ryw0UeNvoJan104aKi2nYelyKs7fsUbpbk+ErdItzQ1fWlxA0/hAV55o Yfszsx7w1d7i7vTC0nAblQP/+dPzRm4nxCEgBQbc= 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.13 097/156] thermal/core/thermal_of: Stop zone device before unregistering it Date: Thu, 22 Jul 2021 18:31:12 +0200 Message-Id: <20210722155631.519039541@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155628.371356843@linuxfoundation.org> References: <20210722155628.371356843@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