Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Chen Zhongjin <chenzhongjin@huawei.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>,
	<lars@metafoo.de>, <daniel.baluta@intel.com>
Subject: Re: [PATCH] iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails
Date: Sat, 12 Nov 2022 17:53:43 +0000	[thread overview]
Message-ID: <20221112175343.759300f5@jic23-huawei> (raw)
In-Reply-To: <20221108032802.168623-1-chenzhongjin@huawei.com>

On Tue, 8 Nov 2022 11:28:02 +0800
Chen Zhongjin <chenzhongjin@huawei.com> wrote:

> 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
> RIP: 0010:__iio_find_sw_trigger_type.isra.3+0x62/0xb0 [industrialio_sw_trigger]
> Call Trace:
> <TASK>
>  iio_register_sw_trigger_type+0x65/0x1f0 [industrialio_sw_trigger]
>  do_one_initcall+0xd0/0x4e0
>  do_init_module+0x1cf/0x6b0
>  load_module+0x65c2/0x7820

I dropped some of the unnecessary noise in the call trace and applied this
to the fixes-togreg branch of iio.git and marked it for stable.

Thanks,

Jonathan

>  ...
> 
> Fixes: b662f809d410 ("iio: core: Introduce IIO software triggers")
> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
> ---
>  drivers/iio/industrialio-sw-trigger.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/industrialio-sw-trigger.c b/drivers/iio/industrialio-sw-trigger.c
> index 994f03a71520..d86a3305d9e8 100644
> --- a/drivers/iio/industrialio-sw-trigger.c
> +++ b/drivers/iio/industrialio-sw-trigger.c
> @@ -58,8 +58,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;
>  }


      reply	other threads:[~2022-11-12 17:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08  3:28 [PATCH] iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails Chen Zhongjin
2022-11-12 17:53 ` Jonathan Cameron [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=20221112175343.759300f5@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=chenzhongjin@huawei.com \
    --cc=daniel.baluta@intel.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@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