Received: by 10.192.165.148 with SMTP id m20csp2468990imm; Sun, 22 Apr 2018 07:41:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/RHtwaM+3Dl2AzFJ7HuZH0RDfL+P0ykRNTmS/HMp+DbvWZ/ARfgZrRhoF8WUWph0olcXzN X-Received: by 2002:a17:902:a603:: with SMTP id u3-v6mr17753055plq.214.1524408073491; Sun, 22 Apr 2018 07:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408073; cv=none; d=google.com; s=arc-20160816; b=AR7G60cDCSjdz+l2p3PmNRt4FIzBIvAO984pSUy0pdUtmXSaHpxyUTtcciZS6+Tt6r AA6AZNOn5ybf1JbyB9I87+PIscrTcs7/zVB+tHCy9jgPhdMQ2FrmCdtJIOTlpgwEqK4q GSlU2reHBBtdbHpC7nv0qRax0sKPo1ErLx5FA6rd4TmknUIhtBUSWbuqA9J5twx8wcbK 8fQl0ynfVV6F7NUaZkUBuFtYqNJkZaJGewAaQnc5lI4qGFZhSmGr20UGTz1XP7jkhbWK Ki6vWcsP5pbQlT4WWjaeEj4m770jWLmIOqdNMkkz2Bt47CAqdaYPoLApx155IL3U8jo+ oxVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XG26shWtzGNpXzVgzRvbQYIdAmxNPUeJ0AYiXJCEC1c=; b=ZvIXsMJLcDqLfLQC95+GwgTkCHVu4X/k6OVpSFabgy68rA+RG5phL1HhNblha/VPRv AQjDEkjovBC8MR2Z4hBpZghAp3ri9w78cOu0RjLkwIJOeyWrcLtsC69VeGNHGJKvxH7s voQMF1rxuVtihRj6q+h4xIyXCtNC4zXn8p0hll6kiHp2ALZ9vQU7hHgyvW3W1kpHtzcv vtkyVFN/p2mTM5ZT+7s225YHAgxqIFjtsh/uFsZKb9JnM/7MgNy+RQUXS7562uHMu2i/ SRxY+39C3eku4FFJUb9DlWU+l2OOjTj6ugPnILQcoN5yAIKs1F3aJ2dVYXnM7oIv6o4x 1VTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k70si8123660pgc.648.2018.04.22.07.40.59; Sun, 22 Apr 2018 07:41:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757197AbeDVOSH (ORCPT + 99 others); Sun, 22 Apr 2018 10:18:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58660 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757146AbeDVOSB (ORCPT ); Sun, 22 Apr 2018 10:18:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9BDA2CD2; Sun, 22 Apr 2018 14:18:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikhail Lappo , Fabio Estevam , Philipp Zabel , Dong Aisheng , Zhang Rui Subject: [PATCH 4.4 63/97] thermal: imx: Fix race condition in imx_thermal_probe() Date: Sun, 22 Apr 2018 15:53:41 +0200 Message-Id: <20180422135308.741318759@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikhail Lappo commit cf1ba1d73a33944d8c1a75370a35434bf146b8a7 upstream. When device boots with T > T_trip_1 and requests interrupt, the race condition takes place. The interrupt comes before THERMAL_DEVICE_ENABLED is set. This leads to an attempt to reading sensor value from irq and disabling the sensor, based on the data->mode field, which expected to be THERMAL_DEVICE_ENABLED, but still stays as THERMAL_DEVICE_DISABLED. Afher this issue sensor is never re-enabled, as the driver state is wrong. Fix this problem by setting the 'data' members prior to requesting the interrupts. Fixes: 37713a1e8e4c ("thermal: imx: implement thermal alarm interrupt handling") Cc: Signed-off-by: Mikhail Lappo Signed-off-by: Fabio Estevam Reviewed-by: Philipp Zabel Acked-by: Dong Aisheng Signed-off-by: Zhang Rui Signed-off-by: Greg Kroah-Hartman --- drivers/thermal/imx_thermal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -589,6 +589,9 @@ static int imx_thermal_probe(struct plat regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN); regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP); + data->irq_enabled = true; + data->mode = THERMAL_DEVICE_ENABLED; + ret = devm_request_threaded_irq(&pdev->dev, data->irq, imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread, 0, "imx_thermal", data); @@ -600,9 +603,6 @@ static int imx_thermal_probe(struct plat return ret; } - data->irq_enabled = true; - data->mode = THERMAL_DEVICE_ENABLED; - return 0; }