All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Szymon Wilczek" <swilczek.lx@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (coretemp) Fix core_data leak on CPUs without PTS
Date: Mon, 10 Aug 2026 19:41:52 +0000	[thread overview]
Message-ID: <20260810194153.5CD7E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810192344.3733721-1-swilczek.lx@gmail.com>

> pdata->core_data is allocated in init_temp_data() when the first core
> temp_data of a package is created, but it is only released from
> destroy_temp_data(), and only in the branch that handles the package
> temp_data.
> 
> Package temp_data is created solely when the CPU supports
> X86_FEATURE_PTS. On a CPU without it, coretemp_cpu_online() never calls
> coretemp_add_core() with pkg_flag set, so pdata->pkg_data stays NULL.
> coretemp_cpu_offline() then skips the removal of the package interface,
> destroy_temp_data() is never called for package data, and the array is
> still allocated when coretemp_device_remove() frees the platform data
> that pointed at it.
> 
> Release the array in coretemp_device_remove(). destroy_temp_data() sets
> pdata->core_data to NULL when it frees it, so the added kfree() is a
> no-op on CPUs that do have PTS.
> 
> Tested on an Intel Core i5-1135G7. The driver was instrumented to log
> every allocation and release of pdata->core_data, and the PTS check in
> coretemp_cpu_online() was patched out to emulate a CPU without package
> thermal support. Without this change the array was allocated and never
> released, and coretemp_device_remove() still saw a non-NULL pointer.
> With it the array is released and the pointer accounting balances. On an
> unmodified build the release still happens via the package temp_data and
> the added kfree() sees NULL, with no slab warnings over repeated module
> load and unload cycles.
> 
> Fixes: 1a793caf6f69 ("hwmon: (coretemp) Use dynamic allocated memory for core temp_data")
> Signed-off-by: Szymon Wilczek <swilczek.lx@gmail.com>

Sashiko has reviewed this patch and found no issues. It looks great!

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


  reply	other threads:[~2026-08-10 19:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 19:23 [PATCH] hwmon: (coretemp) Fix core_data leak on CPUs without PTS Szymon Wilczek
2026-08-10 19:41 ` sashiko-bot [this message]
2026-08-11  2:36 ` 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=20260810194153.5CD7E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=swilczek.lx@gmail.com \
    /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.