iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails
authorChen Zhongjin <chenzhongjin@huawei.com>
Tue, 8 Nov 2022 03:28:02 +0000 (11:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Dec 2022 10:15:40 +0000 (11:15 +0100)
commitaa800ea7aa524ed2fabca1ad00f23697b27b7ddf
treecdd51d9ce1cf82e48c1c0d21181c111e80ce3eeb
parente347d5b993bc41425631d5d5eae6d236626b4457
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>
drivers/iio/industrialio-sw-trigger.c