summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorChen Zhongjin <chenzhongjin@huawei.com>2022-11-08 11:28:02 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-08 11:18:30 +0100
commit9424b6719a00f46ef6e749a0788467ce07883105 (patch)
treef7acd7c4aed2eb66de561ccafa683362c4bf7b68 /drivers
parent514f08941d2aa238b087836828b26a04dbaae2bc (diff)
downloadlinux-9424b6719a00f46ef6e749a0788467ce07883105.tar.gz
linux-9424b6719a00f46ef6e749a0788467ce07883105.tar.bz2
linux-9424b6719a00f46ef6e749a0788467ce07883105.zip
iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails
commit 4ad09d956f8eacff61e67e5b13ba8ebec3232f76 upstream. In iio_register_sw_trigger_type(), configfs_register_default_group() is possible to fail, but the entry add to iio_trigger_types_list is not deleted. This leaves wild in iio_trigger_types_list, which can cause page fault when module is loading again. So fix this by list_del(&t->list) in error path. BUG: unable to handle page fault for address: fffffbfff81d7400 Call Trace: <TASK> iio_register_sw_trigger_type do_one_initcall do_init_module load_module ... Fixes: b662f809d410 ("iio: core: Introduce IIO software triggers") Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com> Link: https://lore.kernel.org/r/20221108032802.168623-1-chenzhongjin@huawei.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iio/industrialio-sw-trigger.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/iio/industrialio-sw-trigger.c b/drivers/iio/industrialio-sw-trigger.c
index bc6b7fb43e3a..b4b177c16865 100644
--- a/drivers/iio/industrialio-sw-trigger.c
+++ b/drivers/iio/industrialio-sw-trigger.c
@@ -61,8 +61,12 @@ int iio_register_sw_trigger_type(struct iio_sw_trigger_type *t)
t->group = configfs_register_default_group(iio_triggers_group, t->name,
&iio_trigger_type_group_type);
- if (IS_ERR(t->group))
+ if (IS_ERR(t->group)) {
+ mutex_lock(&iio_trigger_types_lock);
+ list_del(&t->list);
+ mutex_unlock(&iio_trigger_types_lock);
ret = PTR_ERR(t->group);
+ }
return ret;
}