linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/9] iio: Fix crash in trigger unregister
@ 2013-10-21 21:01 Srinivas Pandruvada
  2013-10-21 21:01 ` [PATCH 2/9] iio: hid-sensors: Add connection type Srinivas Pandruvada
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Srinivas Pandruvada @ 2013-10-21 21:01 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, Srinivas Pandruvada

User space can write a triger name via trigger/current_trigger.
But it is possible that it can't find this name. In this case
iio_trigger_find_by_name will return NULL. Even if it is NULL,
it sets indio_dev->trig to this NULL value. But when iio drivers
calls iio_trigger_unregister, it will crash because it will try
to dereference NULL pointer. So either every driver checks for
NULL before calling iio_trigger_unregister or make sure that
NULL is not assigned because of invalid trigger name. The later
is better and has less impact.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/iio/industrialio-trigger.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index bf5e70a..4dc4247 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -342,13 +342,16 @@ static ssize_t iio_trigger_write_current(struct device *dev,
 	if (oldtrig == trig)
 		return len;
 
-	if (trig && indio_dev->info->validate_trigger) {
+	if (!trig)
+		return -EINVAL;
+
+	if (indio_dev->info->validate_trigger) {
 		ret = indio_dev->info->validate_trigger(indio_dev, trig);
 		if (ret)
 			return ret;
 	}
 
-	if (trig && trig->ops && trig->ops->validate_device) {
+	if (trig->ops && trig->ops->validate_device) {
 		ret = trig->ops->validate_device(trig, indio_dev);
 		if (ret)
 			return ret;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-22 14:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-21 21:01 [PATCH 1/9] iio: Fix crash in trigger unregister Srinivas Pandruvada
2013-10-21 21:01 ` [PATCH 2/9] iio: hid-sensors: Add connection type Srinivas Pandruvada
2013-10-21 21:01 ` [PATCH 3/9] iio: hid-sensors: accelerometer: Add sensitivity Srinivas Pandruvada
2013-10-21 21:01 ` [PATCH 4/9] iio: hid-sensors: gyro : " Srinivas Pandruvada
2013-10-21 21:01 ` [PATCH 5/9] iio: hid-sensors: light/als " Srinivas Pandruvada
2013-10-21 21:01 ` [PATCH 6/9] iio: hid-sensors: magnetometer " Srinivas Pandruvada
2013-10-21 21:01 ` [PATCH 7/9] iio: hid-sensors: Added Inclinometer 3D Srinivas Pandruvada
2013-10-21 21:01 ` [PATCH 8/9] iio: Add channel modifiers for Quaternion Rotations Srinivas Pandruvada
2013-10-21 21:01 ` [PATCH 9/9] iio: hid-sensors: Added device rotation support Srinivas Pandruvada
2013-10-21 21:35 ` [PATCH 1/9] iio: Fix crash in trigger unregister Jonathan Cameron
2013-10-22 14:41   ` Srinivas Pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).