From patchwork Wed Mar 11 13:49:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 11139 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2BDnZsl029677 for ; Wed, 11 Mar 2009 13:49:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754821AbZCKNtd (ORCPT ); Wed, 11 Mar 2009 09:49:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755287AbZCKNtd (ORCPT ); Wed, 11 Mar 2009 09:49:33 -0400 Received: from smtp.nokia.com ([192.100.122.230]:28751 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754311AbZCKNtc (ORCPT ); Wed, 11 Mar 2009 09:49:32 -0400 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx03.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n2BDnIAi029348; Wed, 11 Mar 2009 15:49:28 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 11 Mar 2009 15:49:16 +0200 Received: from mgw-int01.ntc.nokia.com ([172.21.143.96]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 11 Mar 2009 15:49:15 +0200 Received: from maxwell.research.nokia.com (maxwell.research.nokia.com [172.21.50.162]) by mgw-int01.ntc.nokia.com (Switch-3.2.5/Switch-3.2.5) with ESMTP id n2BDnE3B011077; Wed, 11 Mar 2009 15:49:14 +0200 Received: from kaali.localdomain (kaali.localdomain [192.168.239.7]) by maxwell.research.nokia.com (Postfix) with ESMTP id 38AB67000B; Wed, 11 Mar 2009 15:49:14 +0200 (EET) Received: from sailus by kaali.localdomain with local (Exim 4.69) (envelope-from ) id 1LhOo6-0000EJ-3x; Wed, 11 Mar 2009 15:49:14 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: linux-omap@vger.kernel.org, hverkuil@xs4all.nl Subject: [PATCH] omap24xxcam: Fix use count handling if sensor enable fails in open() Date: Wed, 11 Mar 2009 15:49:14 +0200 Message-Id: <1236779354-862-1-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 X-OriginalArrivalTime: 11 Mar 2009 13:49:15.0875 (UTC) FILETIME=[2AF80330:01C9A250] X-Nokia-AV: Clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- drivers/media/video/omap24xxcam.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) 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: