iio: core: Fix double free.
authorMartin Fuzzey <mfuzzey@parkeon.com>
Thu, 19 Feb 2015 14:17:44 +0000 (15:17 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Apr 2015 08:10:19 +0000 (10:10 +0200)
commita8173cd017a912dd333f68bf1c0c31afaf70d4e3
tree7fcd767f8e7f218dba2ce8aaeaadb669b96c9296
parent6cf22b22f477fc59341d96f1d2a56f2b6f09b5e7
iio: core: Fix double free.

commit c1b03ab5e886760bdd38c9c7a27af149046ffe01 upstream.

When an error occurred during event registration memory was freed twice
resulting in kernel memory corruption and a crash in unrelated code.

The problem was caused by
iio_device_unregister_eventset()
iio_device_unregister_sysfs()

being called twice, once on the error path and then
again via iio_dev_release().

Fix this by making these two functions idempotent so they
may be called multiple times.

The problem was observed before applying
78b33216 iio:core: Handle error when mask type is not separate

Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/industrialio-core.c
drivers/iio/industrialio-event.c