From patchwork Tue May 11 04:09:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dillon Min X-Patchwork-Id: 12250725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79975C433B4 for ; Tue, 11 May 2021 11:28:41 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA610616E9 for ; Tue, 11 May 2021 11:28:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA610616E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=7bawwqsUG+kv9Ainw9mAKRGnPcTTKGCsx9MrDbpVhFk=; b=cAkklT/3qUpLyji4GmlsQ/DyzH 5U1xxWajjmx64W0vK0PLhbhvc8X+1lr4jNmGuhkVI9yOBxFJp0Xfo35cPqaaO4BgSPgTdJqfw5igE WGc368AbEMtfE5yY5cjalYoSmvubmXtp8M2dbIW00hbXLKkadg5d3Mpg3Gd7Nrm6gDgGLmXik+SaV qTO2id7p+oGbC7Z64zZsQQArN82TF1w2QWB+FxtrOmTikRAqS6vYPu5//URw7gBR8Dt4hpaIM146T TPj2mGP8hrgcOm/O37s/+ROveaOnzVKeLvxRgl0nI7iiqSvB5ITKN/Ln13J7HLKYyK4EKbvuVMkxF vd0XSKHA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgQXR-00H7t5-9T; Tue, 11 May 2021 11:26:58 +0000 Received: from [2607:7c80:54:e::133] (helo=bombadil.infradead.org) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgJiD-00GEn1-Do for linux-arm-kernel@desiato.infradead.org; Tue, 11 May 2021 04:09:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=V5cc8gqWmhgI8hymJnMxwJpjQF8i+VU2pCJJ8axwstk=; b=EpyvelyeVUb1DPUh6eyRYRJ2y3 s3Z+Dd3DACCBZiq3Z9/LxYeFAQAKemaguRi+Uxp+nO53vOPzjatrzTlEcEobwnnTJYSVlpaMz8F7I ZDhAf081xCKYvLSTNT9yimcpNYE8IN1BnNsNtRjsLPnH+pC/FXIBPD7g1adVKAvCAp4HZH96r+nzX 81MPaUWPSzzIDPjsg72XRNZqhkRlTj3W9TZhrie5Gq8DgZv54Iikhjrk62VH8agpOifE8cbRWYIP3 WU61JwPIiNo5QEVodC5iRljn8pBF7uzC3qAtFskst4k/NTHvbit8lJQGGJI+U1ZXAA5FUn5sosLVE +R69RffQ==; Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgJi8-009HxF-Qk for linux-arm-kernel@lists.infradead.org; Tue, 11 May 2021 04:09:34 +0000 Received: by mail-pl1-x62e.google.com with SMTP id z18so6594085plg.8 for ; Mon, 10 May 2021 21:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=V5cc8gqWmhgI8hymJnMxwJpjQF8i+VU2pCJJ8axwstk=; b=dXYTVILtW0smoS+ZCCp5EKDoSxqxtkmkBGghPetrKwjOh7CMyDUtvatt+o49mlEC+p VCC5qxBMsKrHzec9wcE7cP/ZtBa5s1n5ezpdPDXEX+52xnqqeFma9lOeCczZr4fnozhc o2EAGXFhRjzQpTKXGjRiR/oMXUoyBeesKN2rr+QyW7VYX9SUiUEWcdLXHrgA7C+GDWkE lL8on+iYUS4iGpa3tiXuPqqBnpl517Y83MhhrWrS9SYU3R1DFFMcZumQ4HxmiGOdVTkk Sp9q5PoLoL/CS4wmXnjWPNkzHMIEMB1ItjXny6mpsrlRUyKLrq023pTah9W8ehYDxkQZ 8HUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=V5cc8gqWmhgI8hymJnMxwJpjQF8i+VU2pCJJ8axwstk=; b=jn0hF1I4yekzwgQHlrWvMrYvKeKFq0kj++YBb/ESYdGQEUWkxBQkpBkhRfqr3fF/Af oXyVQ+lgkHcZqbWG4xTdm/QNABilDpHDy0i2bR5aYx/RPn5MtI+LEv9Y1adO7KFwg7Ii VC+GXo0g4uKiAjHzZ1CEfhX/17mw33f85IJLUOQMiKCKM+zPlMSSee4F5WkUvYZ76CfX VBqd1dMH1OKqVIZwe+AnHgzgIITAVhA3TfC7AV5yyxxIHEeA9ucV/x+fS+xDOrVJ742G kVrgrpLv+IMh7zetAgagZU3sH5c7Jdy8x0ZIxT3LksZJCVQnGPQeVZqiAFbwskk9lAzD liwg== X-Gm-Message-State: AOAM5329dmdF7eQW+lD6R6KUGNWetbqyernYGXuxzREjd4g8Xst2Warf MZ06H3STEVKwSpBYF/sGzXL//IPsqPi/+zRVI40= X-Google-Smtp-Source: ABdhPJx92pj68s8jJWnq2LdkDNdYrQb2lFiDBdLcfgK3rBeuv9O5qgLHeqYSp905RMzgPA5h8BA2SQ== X-Received: by 2002:a17:90a:488a:: with SMTP id b10mr31428392pjh.2.1620706170503; Mon, 10 May 2021 21:09:30 -0700 (PDT) Received: from fmin-OptiPlex-7060.nreal.work ([137.59.103.165]) by smtp.gmail.com with ESMTPSA id g18sm12531352pfb.178.2021.05.10.21.09.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 May 2021 21:09:30 -0700 (PDT) From: dillon.minfei@gmail.com To: mchehab+huawei@kernel.org, hverkuil-cisco@xs4all.nl, a.hajda@samsung.com Cc: linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Dillon Min Subject: [PATCH] media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx Date: Tue, 11 May 2021 12:09:24 +0800 Message-Id: <1620706164-28856-1-git-send-email-dillon.minfei@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_210932_910760_EF3825D1 X-CRM114-Status: GOOD ( 11.20 ) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_210932_910760_EF3825D1 X-CRM114-Status: UNSURE ( 7.78 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Dillon Min The m2m_ctx resources was allocated by v4l2_m2m_ctx_init() in g2d_open() should be freed from g2d_release() when it's not used. Fix it Fixes: 918847341af0 ("[media] v4l: add G2D driver for s5p device family") Signed-off-by: Dillon Min --- drivers/media/platform/s5p-g2d/g2d.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c index 15bcb7f6e113..0818fdd3e984 100644 --- a/drivers/media/platform/s5p-g2d/g2d.c +++ b/drivers/media/platform/s5p-g2d/g2d.c @@ -279,6 +279,9 @@ static int g2d_release(struct file *file) v4l2_ctrl_handler_free(&ctx->ctrl_handler); v4l2_fh_del(&ctx->fh); v4l2_fh_exit(&ctx->fh); + mutex_lock(&dev->mutex); + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); + mutex_unlock(&dev->mutex); kfree(ctx); v4l2_info(&dev->v4l2_dev, "instance closed\n"); return 0;