From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796432015; b=qPZ3sEUK4DP6/QGyN+HN2IOf7KIxwoJMwjo0yHlNnNqSXQLwulK92grv/pxZjMBo31mO jbw7yNyOgDDjPQs7IXGQvB3vuAY2f6aXcXFDY8fyP/M8d9ui+YAtgZb3h9LTtknEIoJ9U oHyuXS5C3J2IC5Alvy2+0wemSD70cdS6nYbRok6KeT/ORjasQ3mGlgCqOLJwzV47wEQdj 7ZABxGK0Gq9DUBFQSirtSNsyyVeRpM7yMrNwPR/Yi+8TCT3dZKJ4kA5fCKu7fAJAfwiPb ZsLUnMbjqSvg8sqLdvS20Rf35vxs+gBYq7SWjbBtp7NimOfutZPWPJ+OMzIwryrIi4A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796432015; h=DMARC-Filter:Received:Received:X-Authority-Analysis:DKIM-Signature: Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To:X-AntiAbuse:X-AntiAbuse: X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:X-BWhitelist:X-Source-IP: X-Source-L:X-Exim-ID:X-Source:X-Source-Args:X-Source-Dir: X-Source-Sender:X-Source-Auth:X-Email-Count:X-Org:X-Source-Cap: X-Local-Domain:X-CMAE-Envelope; bh=RUCR6mNFo+23J1RJpovHWduqg6/Mn541V04gx0TumtA=; b=E7rXy6WpERzylxqKxpNOdtLcW8j6WZ/w4LKJDTzmhxdz5mFNLwUXImxF2bZvhfSCbwRU oSRAEHu7SENB2xHpUggmrGHMRCio7y+QNKN2d+BcwjE9m5ybFxNiIPJ65YCm6F+tLj8lB LbAut4US2Apb7IrfP9b0xGYz4pAraXkBRRimY8/Shw5Rf7eJHHJQx0wtYNTHR/x5eyc6S vaQ7M6hogYSduBT7SAFICUunqsq0mOv0j27voFu/ysbAn2w+cWJqDKG9gomdHeAi6SoAm 1HH8n1iKGIZ4xC3NAUtK3G8RgEDlzUOomu+ZgJTV5ZimGy3NGQOG5XjtH3g1GBaPYMg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=roeck-us.net; spf=fail smtp.mailfrom=roeck-us.net; dkim=pass header.d=roeck-us.net header.i=@roeck-us.net header.a=rsa-sha256 header.s=default header.b="3/5sB/Ny"; arc=none smtp.remote-ip=44.202.169.37 Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B21A5606A32C for ; Sat, 5 Dec 2026 00:53:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B21A5606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=roeck-us.net header.i=@roeck-us.net header.a=rsa-sha256 header.s=default header.b=3/5sB/Ny Received: from eig-obgw-5006b.ext.cloudfilter.net ([10.0.29.217]) by cmsmtp with ESMTPS id ZbJzxsDh0V16IZe1oxUx9u; Sat, 05 Dec 2026 00:53:28 +0000 Received: from 162-215-252-36.unifiedlayer.com ([208.91.199.152]) by cmsmtp with ESMTPS id Ze1oxrnKiZHbuZe1oxItZH; Sat, 05 Dec 2026 00:53:28 +0000 X-Authority-Analysis: v=2.4 cv=ML1gmNZl c=1 sm=1 tr=0 ts=6b136088 a=QNED+QcLUkoL9qulTODnwA==:117 a=2cfIYNtKkjgZNaOwnGXpGw==:17 a=kj9zAlcOel0A:10 a=pUM-KoujPXoA:10 a=M0FbrtG7MMAA:10 a=VwQbUJbxAAAA:8 a=pGLkceISAAAA:8 a=OGDEeycC5r07cdTVyPIA:9 a=CjuIK1q_8ugA:10 a=KPbNTLLc3YvdawN95zVk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=In-Reply-To:Content-Type:MIME-Version:References :Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RUCR6mNFo+23J1RJpovHWduqg6/Mn541V04gx0TumtA=; b=3/5sB/NyERlLRb4YFUTNjI33BT gh/ugxOfF5schEuDVVjoxVwKbkG0t7eJX98uUnGqF/xpOXr5H4RTTyzma0SGtxEvrX5RfW9teM4NY ReudKDhj0wfsyoP68iu5Wsr79bKZQuC7kiXfACczzuVI5pHFuZB3ja3jrCK7Flm8jpbkTFl2Z0d+d XktGNtYrlm2IIuuirNcsx0BYKuRojt5nJfM4uUDMPhZAcm24LGzdwRdQFUmmzZl1CxbOYIhLf0Jp1 KDDKIqqo74ywEKhZ4oWiyXSM6UVZoD0pn0l6Skhte38f1L2nPJ64nU8RZ7+yay8aFdYKz8A8BuHfT U9ZIy8bw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:48726 helo=server.roeck-us.net) by bh-25.webhostbox.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.3) (envelope-from ) id 1xZe1n-00000001HZr-39ba; Sat, 05 Dec 2026 06:23:27 +0530 Date: Fri, 4 Dec 2026 16:53:27 -0800 From: Guenter Roeck To: Praneeth Balasubramanian Cc: Jean Delvare , Frank Crawford , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] hwmon: (it87) Lock the device while reading the temperature sensor type Message-ID: <639d12ae-9600-46ef-a4e5-1c3f5f2b446d@roeck-us.net> References: <20261204205016.1788907-1-praneethb2002@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261204205016.1788907-1-praneethb2002@gmail.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-BWhitelist: no X-Source-IP: 108.223.40.66 X-Source-L: No X-Exim-ID: 1xZe1n-00000001HZr-39ba X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 108-223-40-66.lightspeed.sntcca.sbcglobal.net (server.roeck-us.net) [108.223.40.66]:48726 X-Source-Auth: guenter@roeck-us.net X-Email-Count: 2 X-Org: HG=direseller_whb_net_legacy;ORG=directi; X-Source-Cap: cm9lY2s7YWN0aXZzdG07YmgtMjUud2ViaG9zdGJveC5uZXQ= X-Local-Domain: yes X-CMAE-Envelope: MS4xfH98AMi4RdGnIiMslrTxkPj3PIEP+QA88O8LIx2xQXTRQ/9mPsIkDSjm0w9CEENLrYAMc847wmaX7c9o1jDLvzUbD0zr9mwa80C5vRdzDKjB+Ni3ZI+z xkGZupRNnc/TMHuvcPABbtviES66sj9AiUgIIx51kZyHqs0hW6H+xpJq2KrhibYLyHyM5ObL1zYpLLd0+CRikWTkJhWiW+ZZvK/OWxs7SJk6rXvnvKVBdXvE On Fri, Dec 04, 2026 at 12:50:16PM -0800, Praneeth Balasubramanian wrote: > show_temp_type() calls it87_update_device() and then get_temp_type(). > it87_update_device() drops data->update_lock before it returns. Since > commit 6593eac89920 ("hwmon: (it87) Add support to detect sensor type > AMDTSI"), get_temp_type() no longer uses the cached register values but > reads IT87_REG_IFSEL, IT87_REG_TEMP_ENABLE and IT87_REG_TEMP_EXTRA from > the chip. These reads therefore run without update_lock and with SMBus > access enabled, while the comment above it87_read_value() requires both. > > it87_read_value() and it87_write_value() go through one address/data > port pair. If a read of tempN_type races with a sysfs store that holds > the lock, for example set_temp_type(), the address write of one side can > land between the address and data accesses of the other. The store can > then write its value to a different register, or the read returns the > wrong register. > > Take the lock with it87_lock() around get_temp_type(), as > set_temp_type() does. get_temp_type() uses none of the cached values, so > also replace it87_update_device() with dev_get_drvdata(), again as > set_temp_type() does. This avoids taking update_lock twice and an unused > refresh of the cached registers. > > The missing lock was found by a static check that turns the locking rule > in a function's comment into a Clang context-analysis requirement on its > callers. > > Fixes: 6593eac89920 ("hwmon: (it87) Add support to detect sensor type AMDTSI") > Cc: stable@vger.kernel.org > Signed-off-by: Praneeth Balasubramanian Applied. Thanks, Guenter