iio: core: fix ioctl handlers removal
PATCH 1/1 iio: core: fix ioctl handlers removal
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.
--- drivers/iio/industrialio-core.c | 3 --- 1 file changed, 3 deletions(-)
drivers/iio/industrialio-core.c +0 -3
@@ -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);
Signature · 1 line
2.31.1
Quoted 10 lines · Tomasz Duszynski
Currently ioctl handlers are removed twice. For the first time during
iio_device_unregister()then later on insideiio_device_unregister_eventset()andiio_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.
This change is missing this tag:
With that tag added:
Apologies for the breakage.
Also, I wasn't sure if Jonathan or anyone else wanted to do this change.
Thanks for the patch
Alex
Quoted 22 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/industrialio-core.c | 3 --- 1 file changed, 3 deletions(-)drivers/iio/industrialio-core.c +0
-4@@ -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
Quoted 13 lines · Alexandru Ardelean
Quoted 10 lines · Tomasz Duszynski
Currently ioctl handlers are removed twice. For the first time during
iio_device_unregister()then later on insideiio_device_unregister_eventset()andiio_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.
Quoted 8 lines
This change is missing this tag:
Fixes 8dedcc3eee3ac ("iio: core: centralize ioctl() calls to the main chardev")With that tag added:
Apologies for the breakage.
No worries. Will append you ack to v2 then.
Quoted 27 lines
Also, I wasn't sure if Jonathan or anyone else wanted to do this change.
Thanks for the patch
AlexQuoted 22 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/industrialio-core.c | 3 --- 1 file changed, 3 deletions(-)drivers/iio/industrialio-core.c +0
-4@@ -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