diff mbox

omap24xxcam: Fix use count handling if sensor enable fails in open()

Message ID 1236779354-862-1-git-send-email-sakari.ailus@maxwell.research.nokia.com (mailing list archive)
State RFC
Headers show

Commit Message

Sakari Ailus March 11, 2009, 1:49 p.m. UTC
Decrease use count back if omap24xxcam_sensor_enable() fails in
omap24xxcam_open(). Thanks to Hans Verkuil for pointing this out.

Compile tested only.

Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
---
 drivers/media/video/omap24xxcam.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c
index 73eb656..3002051 100644
--- a/drivers/media/video/omap24xxcam.c
+++ b/drivers/media/video/omap24xxcam.c
@@ -1476,10 +1476,8 @@  static int omap24xxcam_open(struct file *file)
 
 	if (atomic_inc_return(&cam->users) == 1) {
 		omap24xxcam_hwinit(cam);
-		if (omap24xxcam_sensor_enable(cam)) {
-			mutex_unlock(&cam->mutex);
+		if (omap24xxcam_sensor_enable(cam))
 			goto out_omap24xxcam_sensor_enable;
-		}
 	}
 	mutex_unlock(&cam->mutex);
 
@@ -1502,7 +1500,9 @@  static int omap24xxcam_open(struct file *file)
 	return 0;
 
 out_omap24xxcam_sensor_enable:
+	atomic_dec(&cam->users);
 	omap24xxcam_poweron_reset(cam);
+	mutex_unlock(&cam->mutex);
 	module_put(cam->sdev->module);
 
 out_try_module_get: