Skip to content

Commit 4ad09d9

Browse files
Chen Zhongjinjic23
authored andcommitted
iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails
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: b662f80 ("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>
1 parent 20690cd commit 4ad09d9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/iio/industrialio-sw-trigger.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ int iio_register_sw_trigger_type(struct iio_sw_trigger_type *t)
5858

5959
t->group = configfs_register_default_group(iio_triggers_group, t->name,
6060
&iio_trigger_type_group_type);
61-
if (IS_ERR(t->group))
61+
if (IS_ERR(t->group)) {
62+
mutex_lock(&iio_trigger_types_lock);
63+
list_del(&t->list);
64+
mutex_unlock(&iio_trigger_types_lock);
6265
ret = PTR_ERR(t->group);
66+
}
6367

6468
return ret;
6569
}

0 commit comments

Comments
 (0)