From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Changyul Lee <lcy8047@gmail.com>,
Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y 2/2] iio: trigger: free the trigger ID after device_del()
Date: Thu, 26 Nov 2026 12:21:35 -0500 [thread overview]
Message-ID: <20261126172128.2745277-2-sashal@kernel.org> (raw)
In-Reply-To: <20261126172128.2745277-1-sashal@kernel.org>
From: Changyul Lee <lcy8047@gmail.com>
[ Upstream commit d32bf759801e6df23038dc834622a122ec76a4dd ]
iio_trigger_unregister() returns the trigger ID to iio_trigger_ida
before device_del() removes the "trigger<N>" device. A trigger
registered in between can get the same ID, and its device_add() fails:
sysfs: cannot create duplicate filename '/bus/iio/devices/trigger0'
For example, adding a sysfs trigger while an hrtimer trigger is being
removed through configfs, or the other way around, hits this because the
two paths do not share a lock.
Free the ID after device_del(), as the error path of
iio_trigger_register() already does, and drop the "Possible issue in
here" comment.
Fixes: 1637db44413e ("Staging: IIO: Trigger support added to core.")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iio/industrialio-trigger.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index bf09ddee2bf7f..721ee9ae946bd 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -109,9 +109,8 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
list_del(&trig_info->list);
mutex_unlock(&iio_trigger_list_lock);
- ida_free(&iio_trigger_ida, trig_info->id);
- /* Possible issue in here */
device_del(&trig_info->dev);
+ ida_free(&iio_trigger_ida, trig_info->id);
}
EXPORT_SYMBOL(iio_trigger_unregister);
--
2.53.0
prev parent reply other threads:[~2026-11-26 17:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 12:45 FAILED: patch "[PATCH] iio: trigger: free the trigger ID after device_del()" failed to apply to 5.15-stable tree gregkh
2026-11-26 17:21 ` [PATCH 5.15.y 1/2] iio: Directly use ida_alloc()/free() Sasha Levin
2026-11-26 17:21 ` Sasha Levin [this message]
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=20261126172128.2745277-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=lcy8047@gmail.com \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox