* FAILED: patch "[PATCH] iio: trigger: free the trigger ID after device_del()" failed to apply to 5.15-stable tree
@ 2026-11-25 12:45 gregkh
2026-11-26 17:21 ` [PATCH 5.15.y 1/2] iio: Directly use ida_alloc()/free() Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-11-25 12:45 UTC (permalink / raw)
To: lcy8047, jonathan.cameron; +Cc: stable
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x d32bf759801e6df23038dc834622a122ec76a4dd
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112508-repose-unboxed-3df2@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d32bf759801e6df23038dc834622a122ec76a4dd Mon Sep 17 00:00:00 2001
From: Changyul Lee <lcy8047@gmail.com>
Date: Fri, 6 Nov 2026 12:47:37 -0500
Subject: [PATCH] iio: trigger: free the trigger ID after device_del()
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>
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index fc4651490d42..1078ffa8e06a 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -105,9 +105,8 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
scoped_guard(mutex, &iio_trigger_list_lock)
list_del(&trig_info->list);
- 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);
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 5.15.y 1/2] iio: Directly use ida_alloc()/free() 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 ` Sasha Levin 2026-11-26 17:21 ` [PATCH 5.15.y 2/2] iio: trigger: free the trigger ID after device_del() Sasha Levin 0 siblings, 1 reply; 3+ messages in thread From: Sasha Levin @ 2026-11-26 17:21 UTC (permalink / raw) To: stable; +Cc: keliu, Jonathan Cameron, Sasha Levin From: keliu <liuke94@huawei.com> [ Upstream commit 319dbcd84fd2676afb2bcfee575fbc1fce474ec3 ] Use ida_alloc()/ida_free() instead of deprecated ida_simple_get()/ida_simple_remove() . Signed-off-by: keliu <liuke94@huawei.com> Link: https://lore.kernel.org/r/20220527091739.2949426-1-liuke94@huawei.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Stable-dep-of: d32bf759801e ("iio: trigger: free the trigger ID after device_del()") Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/iio/industrialio-core.c | 6 +++--- drivers/iio/industrialio-trigger.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index c52b79a86ab49..d58cc1994c80e 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1651,7 +1651,7 @@ static void iio_dev_release(struct device *device) iio_device_detach_buffers(indio_dev); - ida_simple_remove(&iio_ida, iio_dev_opaque->id); + ida_free(&iio_ida, iio_dev_opaque->id); kfree(iio_dev_opaque); } @@ -1694,7 +1694,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) mutex_init(&iio_dev_opaque->info_exist_lock); INIT_LIST_HEAD(&iio_dev_opaque->channel_attr_list); - iio_dev_opaque->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL); + iio_dev_opaque->id = ida_alloc(&iio_ida, GFP_KERNEL); if (iio_dev_opaque->id < 0) { /* cannot use a dev_err as the name isn't available */ pr_err("failed to get device id\n"); @@ -1703,7 +1703,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) } if (dev_set_name(&indio_dev->dev, "iio:device%d", iio_dev_opaque->id)) { - ida_simple_remove(&iio_ida, iio_dev_opaque->id); + ida_free(&iio_ida, iio_dev_opaque->id); kfree(iio_dev_opaque); return NULL; } diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index f85478742d505..bf09ddee2bf7f 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -71,7 +71,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info, trig_info->owner = this_mod; - trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); + trig_info->id = ida_alloc(&iio_trigger_ida, GFP_KERNEL); if (trig_info->id < 0) return trig_info->id; @@ -98,7 +98,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info, mutex_unlock(&iio_trigger_list_lock); device_del(&trig_info->dev); error_unregister_id: - ida_simple_remove(&iio_trigger_ida, trig_info->id); + ida_free(&iio_trigger_ida, trig_info->id); return ret; } EXPORT_SYMBOL(__iio_trigger_register); @@ -109,7 +109,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info) list_del(&trig_info->list); mutex_unlock(&iio_trigger_list_lock); - ida_simple_remove(&iio_trigger_ida, trig_info->id); + ida_free(&iio_trigger_ida, trig_info->id); /* Possible issue in here */ device_del(&trig_info->dev); } -- 2.53.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 5.15.y 2/2] iio: trigger: free the trigger ID after device_del() 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 0 siblings, 0 replies; 3+ messages in thread From: Sasha Levin @ 2026-11-26 17:21 UTC (permalink / raw) To: stable; +Cc: Changyul Lee, Jonathan Cameron, Sasha Levin 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 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-26 17:21 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH 5.15.y 2/2] iio: trigger: free the trigger ID after device_del() Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox