All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: anna-maria@linutronix.de, frederic@kernel.org, tglx@kernel.org
Cc: linux-kernel@vger.kernel.org, Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] clockevents: Match the CPU when unbinding devices via sysfs
Date: Sun,  1 Nov 2026 16:11:20 +0200	[thread overview]
Message-ID: <20261101141120.367124-1-thnkslprpt@gmail.com> (raw)

Clockevent devices belonging to different CPUs can share the same
name. The sysfs unbind handler selects the first matching name from
the global device list, which can cause a request for one CPU to
unbind another CPU's device or incorrectly return -EBUSY.

Check the device's CPU mask when selecting the clockevent to unbind
so that the request targets a device eligible for the specified CPU.

Fixes: 03e13cf5ee60 ("clockevents: Implement unbind functionality")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 kernel/time/clockevents.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 62ad7c000386..05e9d966b024 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -756,7 +756,8 @@ static ssize_t unbind_device_store(struct device *dev,
 	mutex_lock(&clockevents_mutex);
 	raw_spin_lock_irq(&clockevents_lock);
 	list_for_each_entry(iter, &clockevent_devices, list) {
-		if (!strcmp(iter->name, name)) {
+		if (!strcmp(iter->name, name) &&
+		    cpumask_test_cpu(dev->id, iter->cpumask)) {
 			ret = __clockevents_try_unbind(iter, dev->id);
 			ce = iter;
 			break;

base-commit: cbbddb6b08cc9900a87cccaa9b22bbe06aa4f50a
-- 
2.53.0


             reply	other threads:[~2026-11-01 14:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 14:11 Avi Weiss [this message]
2026-11-03 13:52 ` [PATCH] clockevents: Match the CPU when unbinding devices via sysfs Frederic Weisbecker
2026-11-09 19:53 ` [tip: timers/core] " tip-bot2 for Avi Weiss

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=20261101141120.367124-1-thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=anna-maria@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@kernel.org \
    /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.