From patchwork Tue Nov 1 08:08:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Songjun Wu X-Patchwork-Id: 9407051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E245E60234 for ; Tue, 1 Nov 2016 08:12:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D446129605 for ; Tue, 1 Nov 2016 08:12:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C755829607; Tue, 1 Nov 2016 08:12:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7EA8829605 for ; Tue, 1 Nov 2016 08:12:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1U8r-0000sN-Gg; Tue, 01 Nov 2016 08:09:57 +0000 Received: from exsmtp02.microchip.com ([198.175.253.38] helo=email.microchip.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1U8n-0000rf-OH for linux-arm-kernel@lists.infradead.org; Tue, 01 Nov 2016 08:09:54 +0000 Received: from shaarm01.corp.atmel.com (10.10.76.4) by chn-sv-exch02.mchp-main.com (10.10.76.38) with Microsoft SMTP Server id 14.3.181.6; Tue, 1 Nov 2016 01:09:30 -0700 From: Songjun Wu To: Subject: [PATCH] [media] atmel-isc: release the filehandle if it's not the only one. Date: Tue, 1 Nov 2016 16:08:46 +0800 Message-ID: <1477987726-4257-1-git-send-email-songjun.wu@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161101_010953_833204_4E4016AD X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Songjun Wu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Release the filehandle in 'isc_open' if it's not the only filehandle opened for the associated video_device. Signed-off-by: Songjun Wu --- drivers/media/platform/atmel/atmel-isc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c index 8e25d3f..5e08404 100644 --- a/drivers/media/platform/atmel/atmel-isc.c +++ b/drivers/media/platform/atmel/atmel-isc.c @@ -926,21 +926,21 @@ static int isc_open(struct file *file) if (ret < 0) goto unlock; - if (!v4l2_fh_is_singular_file(file)) - goto unlock; + ret = !v4l2_fh_is_singular_file(file); + if (ret) + goto fh_rel; ret = v4l2_subdev_call(sd, core, s_power, 1); - if (ret < 0 && ret != -ENOIOCTLCMD) { - v4l2_fh_release(file); - goto unlock; - } + if (ret < 0 && ret != -ENOIOCTLCMD) + goto fh_rel; ret = isc_set_fmt(isc, &isc->fmt); - if (ret) { + if (ret) v4l2_subdev_call(sd, core, s_power, 0); - v4l2_fh_release(file); - } +fh_rel: + if (ret) + v4l2_fh_release(file); unlock: mutex_unlock(&isc->lock); return ret;