iio: core: Fix double free.
authorMartin Fuzzey <mfuzzey@parkeon.com>
Thu, 19 Feb 2015 14:17:44 +0000 (15:17 +0100)
committerSasha Levin <sasha.levin@oracle.com>
Fri, 24 Apr 2015 21:13:50 +0000 (17:13 -0400)
commit42ec319b4475d48340aedfd8ff9f14d5ae70c009
treed7598fcbf7fbc3c7f6af401d7bb864e9c272c77e
parent382fd035e6c1eff2b807663bc5d4672408d31c53
iio: core: Fix double free.

[ Upstream commit c1b03ab5e886760bdd38c9c7a27af149046ffe01 ]

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>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/iio/industrialio-core.c
drivers/iio/industrialio-event.c