From patchwork Fri Jul 3 10:04:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 6713881 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E9CD69F457 for ; Fri, 3 Jul 2015 10:05:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 108FA2073B for ; Fri, 3 Jul 2015 10:05:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0518D2076D for ; Fri, 3 Jul 2015 10:05:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754938AbbGCKF3 (ORCPT ); Fri, 3 Jul 2015 06:05:29 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:59743 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754644AbbGCKF1 (ORCPT ); Fri, 3 Jul 2015 06:05:27 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NQW0089UPD1RN10@mailout4.w1.samsung.com>; Fri, 03 Jul 2015 11:05:25 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-4e-55965e6511a2 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id B1.F4.05269.56E56955; Fri, 3 Jul 2015 11:05:25 +0100 (BST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NQW006OCPCWCS70@eusync2.samsung.com>; Fri, 03 Jul 2015 11:05:24 +0100 (BST) From: Andrzej Pietrasiewicz To: linux-samsung-soc@vger.kernel.org, linux-media@vger.kernel.org Cc: Andrzej Pietrasiewicz , Bartlomiej Zolnierkiewicz , Mauro Carvalho Chehab , Sylwester Nawrocki , Jacek Anaszewski Subject: [PATCH] media: s5p-jpeg: Eliminate double kfree Date: Fri, 03 Jul 2015 12:04:38 +0200 Message-id: <1435917878-27545-1-git-send-email-andrzej.p@samsung.com> X-Mailer: git-send-email 1.7.10.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPJMWRmVeSWpSXmKPExsVy+t/xK7qpcdNCDRbcYLSY9bKdxWLjjPWs Fr1XnzNa9GzYymox4/w+JovVzyosDr9pZ3Vg99jSf5fdo2/LKkaPz5vkApijuGxSUnMyy1KL 9O0SuDLuPL7MVLBPrOLF5OQGxl3CXYycHBICJhJtc+8xQthiEhfurWfrYuTiEBJYyiixsmUj C4TTwiQxqe06O0gVm4CxxN6DHWAdIgJOEov3/2MFKWIW+MUocXPGJ7CEsICFxO6Fk5i7GNk5 WARUJX7Vg0R5BVwlFvy6yAKxTFGi+9kEtgmM3AsYGVYxiqaWJhcUJ6XnGukVJ+YWl+al6yXn 525ihATD1x2MS49ZHWIU4GBU4uG9cHpqqBBrYllxZe4hRgkOZiUR3ufB00KFeFMSK6tSi/Lj i0pzUosPMUpzsCiJ887c9T5ESCA9sSQ1OzW1ILUIJsvEwSnVwKjJraMcnapXt6IrWu5ncOr0 1qqlLgXtF2NW2i99uTtUYoaxo3NHh2HpLIla83d2KWv9irvXyDU2GEfmNT+/sNzxzbQYM8VE /kTtKReP5l05lPZgR43Hkpsvb0y408y7WuTDyfUb+16zzCyrYLjA/0O52kD14q01/3/Fdaen 7D27Odf3tsr8KiWW4oxEQy3mouJEAMCjrYICAgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP video_unregister_device() calls device_unregister(), which calls put_device(), which calls kobject_put(), and if this is the last reference then kobject_release() is called, which calls kobject_cleanup(), which calls ktype's release method which happens to be device_release() in this case, which calls dev->release(), which happens to be v4l2_device_release() in this case, which calls vdev->release(), which happens to be video_device_release(). But video_device_release() is called explicitly both in error recovery path of s5p_jpeg_probe() and in s5p_jpeg_remove(). The pointers in question are not nullified between the two calls, so this is harmful. This patch fixes the driver so that video_device_release() is not called twice for the same object. Rebased onto Mauro's master. Signed-off-by: Andrzej Pietrasiewicz --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index bfbf157..9690f9d 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -2544,7 +2544,8 @@ static int s5p_jpeg_probe(struct platform_device *pdev) ret = video_register_device(jpeg->vfd_encoder, VFL_TYPE_GRABBER, -1); if (ret) { v4l2_err(&jpeg->v4l2_dev, "Failed to register video device\n"); - goto enc_vdev_alloc_rollback; + video_device_release(jpeg->vfd_encoder); + goto vb2_allocator_rollback; } video_set_drvdata(jpeg->vfd_encoder, jpeg); @@ -2572,7 +2573,8 @@ static int s5p_jpeg_probe(struct platform_device *pdev) ret = video_register_device(jpeg->vfd_decoder, VFL_TYPE_GRABBER, -1); if (ret) { v4l2_err(&jpeg->v4l2_dev, "Failed to register video device\n"); - goto dec_vdev_alloc_rollback; + video_device_release(jpeg->vfd_decoder); + goto enc_vdev_register_rollback; } video_set_drvdata(jpeg->vfd_decoder, jpeg); @@ -2589,15 +2591,9 @@ static int s5p_jpeg_probe(struct platform_device *pdev) return 0; -dec_vdev_alloc_rollback: - video_device_release(jpeg->vfd_decoder); - enc_vdev_register_rollback: video_unregister_device(jpeg->vfd_encoder); -enc_vdev_alloc_rollback: - video_device_release(jpeg->vfd_encoder); - vb2_allocator_rollback: vb2_dma_contig_cleanup_ctx(jpeg->alloc_ctx); @@ -2622,9 +2618,7 @@ static int s5p_jpeg_remove(struct platform_device *pdev) pm_runtime_disable(jpeg->dev); video_unregister_device(jpeg->vfd_decoder); - video_device_release(jpeg->vfd_decoder); video_unregister_device(jpeg->vfd_encoder); - video_device_release(jpeg->vfd_encoder); vb2_dma_contig_cleanup_ctx(jpeg->alloc_ctx); v4l2_m2m_release(jpeg->m2m_dev); v4l2_device_unregister(&jpeg->v4l2_dev);