From patchwork Fri Oct 7 20:39:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 9367489 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 4D0016075E for ; Fri, 7 Oct 2016 20:39:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EE61297EF for ; Fri, 7 Oct 2016 20:39:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 336CE29832; Fri, 7 Oct 2016 20:39:53 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AC57297EF for ; Fri, 7 Oct 2016 20:39:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754864AbcJGUjv (ORCPT ); Fri, 7 Oct 2016 16:39:51 -0400 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:34148 "EHLO s-opensource.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754533AbcJGUju (ORCPT ); Fri, 7 Oct 2016 16:39:50 -0400 Received: from localhost (localhost [127.0.0.1]) by s-opensource.com (Postfix) with ESMTP id 82FF5A0E7A; Fri, 7 Oct 2016 20:39:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osg.samsung.com Received: from s-opensource.com ([127.0.0.1]) by localhost (s-opensource.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mIYr80NyRgT1; Fri, 7 Oct 2016 20:39:42 +0000 (UTC) Received: from minerva.localdomain (unknown [181.121.136.80]) by s-opensource.com (Postfix) with ESMTPSA id E21AAA0E77; Fri, 7 Oct 2016 20:39:38 +0000 (UTC) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Mauro Carvalho Chehab , Marek Szyprowski , Krzysztof Kozlowski , Kukjin Kim , Hans Verkuil , Inki Dae , linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki , Shuah Khan , Nicolas Dufresne , linux-media@vger.kernel.org, Javier Martinez Canillas Subject: [PATCH 1/3] [media] exynos-gsc: don't release a non-dynamically allocated video_device Date: Fri, 7 Oct 2016 17:39:17 -0300 Message-Id: <1475872759-17969-2-git-send-email-javier@osg.samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475872759-17969-1-git-send-email-javier@osg.samsung.com> References: <1475872759-17969-1-git-send-email-javier@osg.samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The struct v4l2_device instance for the G-Scaler is not dyanmically allocated but a member of the struct gsc_dev. In fact, the assigned .release callback is video_device_release_empty(). But gsc_register_m2m_device() attempts to release the v4l2_device by calling video_device_release() in its error path. This is wrong since the v4l2_device wasn't allocated directly and will be freed once its parent struct gsc_dev is freed. While being there, rename the remaining goto label in the error path to something that better explains the error path cleanup. Signed-off-by: Javier Martinez Canillas --- drivers/media/platform/exynos-gsc/gsc-m2m.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c index e2a16b52f87d..a1cac52ea230 100644 --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c @@ -760,24 +760,21 @@ int gsc_register_m2m_device(struct gsc_dev *gsc) gsc->m2m.m2m_dev = v4l2_m2m_init(&gsc_m2m_ops); if (IS_ERR(gsc->m2m.m2m_dev)) { dev_err(&pdev->dev, "failed to initialize v4l2-m2m device\n"); - ret = PTR_ERR(gsc->m2m.m2m_dev); - goto err_m2m_r1; + return PTR_ERR(gsc->m2m.m2m_dev); } ret = video_register_device(&gsc->vdev, VFL_TYPE_GRABBER, -1); if (ret) { dev_err(&pdev->dev, "%s(): failed to register video device\n", __func__); - goto err_m2m_r2; + goto err_m2m_release; } pr_debug("gsc m2m driver registered as /dev/video%d", gsc->vdev.num); return 0; -err_m2m_r2: +err_m2m_release: v4l2_m2m_release(gsc->m2m.m2m_dev); -err_m2m_r1: - video_device_release(gsc->m2m.vfd); return ret; }