From patchwork Tue Aug 14 06:58:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 1318421 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 599633FC81 for ; Tue, 14 Aug 2012 06:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752851Ab2HNG7Q (ORCPT ); Tue, 14 Aug 2012 02:59:16 -0400 Received: from rcsinet15.oracle.com ([148.87.113.117]:26639 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391Ab2HNG7P (ORCPT ); Tue, 14 Aug 2012 02:59:15 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q7E6x6Jt005311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 14 Aug 2012 06:59:07 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q7E6x3Qb022707 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 14 Aug 2012 06:59:04 GMT Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q7E6x37R028077; Tue, 14 Aug 2012 01:59:03 -0500 Received: from elgon.mountain (/41.212.103.53) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 Aug 2012 23:59:02 -0700 Date: Tue, 14 Aug 2012 09:58:56 +0300 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Hans Verkuil , Marek Szyprowski , Tomasz =?utf-8?Q?Mo=C5=84?= , Guennadi Liakhovetski , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] [media] mem2mem_testdev: unlock and return error code properly Message-ID: <20120814065856.GC4791@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org We recently added locking to this function, but there was an error path which accidentally returned holding a lock. Also we returned zero on failure on some paths instead of the error code. Signed-off-by: Dan Carpenter Acked-by: Marek Szyprowski --- Applies to linux-next. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c index 0aa8c47..0b496f3 100644 --- a/drivers/media/video/mem2mem_testdev.c +++ b/drivers/media/video/mem2mem_testdev.c @@ -911,10 +911,9 @@ static int m2mtest_open(struct file *file) v4l2_ctrl_new_custom(hdl, &m2mtest_ctrl_trans_time_msec, NULL); v4l2_ctrl_new_custom(hdl, &m2mtest_ctrl_trans_num_bufs, NULL); if (hdl->error) { - int err = hdl->error; - + rc = hdl->error; v4l2_ctrl_handler_free(hdl); - return err; + goto open_unlock; } ctx->fh.ctrl_handler = hdl; v4l2_ctrl_handler_setup(hdl); @@ -946,7 +945,7 @@ static int m2mtest_open(struct file *file) open_unlock: mutex_unlock(&dev->dev_mutex); - return 0; + return rc; } static int m2mtest_release(struct file *file)