Skip to contentSkip to conversation

iio: double unlock on error path

PATCH Applied Dan Carpenter 2 participants 2 messages Jul 11, 2012 – Jul 12, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: double unlock on error path

We should be holding the mutex when we goto error_free_chans.

drivers/iio/inkern.c +2 -1
index e2aded0..b5afc2f 100644
@@ -198,11 +198,12 @@ struct iio_channel *iio_channel_get_all(const char *name)
 		iio_device_get(chans[mapind].indio_dev);
 		mapind++;
 	}
-	mutex_unlock(&iio_map_list_lock);
 	if (mapind = 0) {
 		ret = -ENODEV;
 		goto error_free_chans;
 	}
+	mutex_unlock(&iio_map_list_lock);
+
 	return chans;
 
 error_free_chans:
maintainer Applied
#1 lore raw
Quoted 3 lines · Dan Carpenter

We should be holding the mutex when we goto error_free_chans.

merged to fixes-togreg branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git

and pull request sent. Thanks.

Quoted 20 lines
drivers/iio/inkern.c +2 -1
index e2aded0..b5afc2f 100644
@@ -198,11 +198,12 @@ struct iio_channel *iio_channel_get_all(const char *name)
 		iio_device_get(chans[mapind].indio_dev);
 		mapind++;
 	}
-	mutex_unlock(&iio_map_list_lock);
 	if (mapind = 0) {
 		ret = -ENODEV;
 		goto error_free_chans;
 	}
+	mutex_unlock(&iio_map_list_lock);
+
 	return chans;
 
 error_free_chans: