All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tomasz.duszynski@octakon.com>
To: <linux-iio@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <jic23@kernel.org>,
	<lars@metafoo.de>, <ardeleanalex@gmail.com>,
	Tomasz Duszynski <tomasz.duszynski@octakon.com>
Subject: [PATCH v2] iio: core: fix ioctl handlers removal
Date: Fri, 23 Apr 2021 10:02:44 +0200	[thread overview]
Message-ID: <20210423080244.2790-1-tomasz.duszynski@octakon.com> (raw)

Currently ioctl handlers are removed twice. For the first time during
iio_device_unregister() then later on inside
iio_device_unregister_eventset() and iio_buffers_free_sysfs_and_mask().
Double free leads to kernel panic.

Fix this by not touching ioctl handlers list directly but rather
letting code responsible for registration call the matching cleanup
routine itself.

Fixes: 8dedcc3eee3ac ("iio: core: centralize ioctl() calls to the main chardev")
Signed-off-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Acked-by: Alexandru Ardelean <ardeleanalex@gmail.com>
---
v2:
* add fixes tag and ack

 drivers/iio/industrialio-core.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index d92c58a94fe4..98944cfc7331 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1939,9 +1939,6 @@ void iio_device_unregister(struct iio_dev *indio_dev)

 	indio_dev->info = NULL;

-	list_for_each_entry_safe(h, t, &iio_dev_opaque->ioctl_handlers, entry)
-		list_del(&h->entry);
-
 	iio_device_wakeup_eventset(indio_dev);
 	iio_buffer_wakeup_poll(indio_dev);

--
2.31.1


             reply	other threads:[~2021-04-23  8:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23  8:02 Tomasz Duszynski [this message]
2021-04-24 10:52 ` [PATCH v2] iio: core: fix ioctl handlers removal Jonathan Cameron
2021-04-24 12:09   ` Tomasz Duszynski

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=20210423080244.2790-1-tomasz.duszynski@octakon.com \
    --to=tomasz.duszynski@octakon.com \
    --cc=ardeleanalex@gmail.com \
    --cc=jic23@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.