From patchwork Mon Nov 14 14:09:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9427595 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 1096160755 for ; Mon, 14 Nov 2016 14:10:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2C6E28774 for ; Mon, 14 Nov 2016 14:09:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E793428780; Mon, 14 Nov 2016 14:09:59 +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 2971828774 for ; Mon, 14 Nov 2016 14:09:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752250AbcKNOJu (ORCPT ); Mon, 14 Nov 2016 09:09:50 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:47985 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753481AbcKNOJr (ORCPT ); Mon, 14 Nov 2016 09:09:47 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGM009TNY07Q380@mailout2.w1.samsung.com>; Mon, 14 Nov 2016 14:09:43 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161114140942eucas1p2185e47ca335c434bc1872c292671d36c~G7z8_RvRq2513725137eucas1p25; Mon, 14 Nov 2016 14:09:42 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 92.EB.11330.6A5C9285; Mon, 14 Nov 2016 14:09:42 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161114140941eucas1p259a5ef794e4349614f6212cc251b6995~G7z8PqRD11055610556eucas1p2C; Mon, 14 Nov 2016 14:09:41 +0000 (GMT) X-AuditID: cbfec7f2-f79556d000002c42-38-5829c5a6f674 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 3A.1B.07726.9A5C9285; Mon, 14 Nov 2016 14:09:45 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGM00KD9XZYIX10@eusync3.samsung.com>; Mon, 14 Nov 2016 14:09:41 +0000 (GMT) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Krzysztof Kozlowski , Seung-Woo Kim , Bartlomiej Zolnierkiewicz , Javier Martinez Canillas , Andrzej Hajda , Shuah Khan , Luis de Bethencourt Subject: [PATCH] s5p-mfc: Fix clock management in s5p_mfc_release function Date: Mon, 14 Nov 2016 15:09:26 +0100 Message-id: <1479132566-477-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsWy7djP87rLjmpGGDyeJGhxa905VouNM9az Wrx5u4bJ4vz5DewWPRu2slrMOL+PyeLovGmMFmuP3GW3OPymndVi6pcPLBYzJr9kc+D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eQwBJGiZnzbkI5TUwSTc2tbCBVbAKGEl1vu8BsEQEniYWz/rKDFDELzGSW 2LXqM1hCWMBLYu23XiCbg4NFQFVi5S5TkDCvgJtEx6kDrBDb5CROHpvMOoGRewEjwypGkdTS 4tz03GJDveLE3OLSvHS95PzcTYzAwN127OfmHYyXNgYfYhTgYFTi4e3I14gQYk0sK67MPcQo wcGsJMIrDgx7Id6UxMqq1KL8+KLSnNTiQ4ymQLsnMkuJJucDoyqvJN7QxNDc0tDI2MLC3MhI SZy35MOVcCGB9MSS1OzU1ILUIpg+Jg5OqQbGJqPlueUZYRGrUt9ubtT96/Hz6gQnNrETrgyN GUUCCfOM8m2eX789Z+r31w+3Olrvvnr4X/fOUsminy8cNCzWbbvTeGUSf/fKt/lXb9p/UxbZ 8nx5bAu7oPGNm0GhOh+0P8zRXDXp5qTMWCM3ldl3Lnc4K/fLrUubFtqek+e55svqvFOrGHz4 lViKMxINtZiLihMBuKC9hnICAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161114140941eucas1p259a5ef794e4349614f6212cc251b6995 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161114140941eucas1p259a5ef794e4349614f6212cc251b6995 X-RootMTR: 20161114140941eucas1p259a5ef794e4349614f6212cc251b6995 References: 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 Clock control indirectly requires access to MFC device, so call it only if we are sure that the device exists in s5p_mfc_release function. s5p_mfc_remove() calls s5p_mfc_final_pm(), which releases all PM related resources, including clocks, so any call to clocks related functions is not valid after s5p_mfc_final_pm(). Fixes: d695c12 ("[media] media: s5p-mfc fix invalid memory access from s5p_mfc_release()") Signed-off-by: Marek Szyprowski --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 0c8a4616e827..a0a29194ccd1 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -940,10 +940,11 @@ static int s5p_mfc_release(struct file *file) mfc_debug_enter(); if (dev) mutex_lock(&dev->mfc_mutex); - s5p_mfc_clock_on(); vb2_queue_release(&ctx->vq_src); vb2_queue_release(&ctx->vq_dst); if (dev) { + s5p_mfc_clock_on(); + /* Mark context as idle */ clear_work_bit_irqsave(ctx); /* @@ -965,9 +966,9 @@ static int s5p_mfc_release(struct file *file) if (s5p_mfc_power_off() < 0) mfc_err("Power off failed\n"); } + mfc_debug(2, "Shutting down clock\n"); + s5p_mfc_clock_off(); } - mfc_debug(2, "Shutting down clock\n"); - s5p_mfc_clock_off(); if (dev) dev->ctx[ctx->num] = NULL; s5p_mfc_dec_ctrls_delete(ctx);