mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@kernel.org>
To: krzk@kernel.org
Cc: josef@toxicpanda.com, linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] w1: Fix the lifetime of slaves and their master
Date: Thu, 19 Nov 2026 20:12:12 +0000	[thread overview]
Message-ID: <20261119-w1-slave-release-v1-0-c2948c825d08@gmail.com> (raw)

w1_unref_slave() frees a slave right after unregistering its device,
while the device's release callback still uses the slave and its
master. Since commit 9fcbbac5ded4 removing a slave no longer waits for
that callback, so a delayed release (or any late reference to the
slave device) runs on freed memory.

Patch 1 frees the slave from its release callback. Patch 2 makes the
slave hold a reference to the master until then, since the master can
otherwise be freed before the delayed release of its last slave.

Found with a static analysis tool and checked by hand. Both problems
reproduce under KASAN with CONFIG_DEBUG_KOBJECT_RELEASE and a test w1
master in QEMU; details below the --- line of each patch.

---
Suyuan Wang (2):
      w1: Free the slave from its device release callback
      w1: Keep the master alive until the slave is released

 drivers/w1/w1.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)



             reply	other threads:[~2026-11-19 20:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 20:12 Suyuan Wang via B4 Relay [this message]
2026-11-19 20:12 ` [PATCH 1/2] w1: Free the slave from its device release callback Suyuan Wang via B4 Relay
2026-11-19 20:12 ` [PATCH 2/2] w1: Keep the master alive until the slave is released Suyuan Wang via B4 Relay

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=20261119-w1-slave-release-v1-0-c2948c825d08@gmail.com \
    --to=devnull+shyckless.gmail.com@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shyckless@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®