All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Praneeth Balasubramanian" <praneethb2002@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2] hwmon: (it87) Lock the device while reading the temperature sensor type
Date: Fri, 04 Dec 2026 21:00:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-250652@kernel.org> (raw)
In-Reply-To: <20261204205016.1788907-1-praneethb2002@gmail.com>

> 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 <praneethb2002@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204205016.1788907-1-praneethb2002@gmail.com?part=1

  reply	other threads:[~2026-12-04 21:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 20:50 [PATCH v2] hwmon: (it87) Lock the device while reading the temperature sensor type Praneeth Balasubramanian
2026-12-04 21:00 ` sashiko-bot [this message]
2026-12-05  0:53 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-250652@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=praneethb2002@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.