From patchwork Mon Mar 5 07:45:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 10258275 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 E690F60134 for ; Mon, 5 Mar 2018 07:46:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4C7328942 for ; Mon, 5 Mar 2018 07:46:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C924A28962; Mon, 5 Mar 2018 07:46:10 +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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 57DE828942 for ; Mon, 5 Mar 2018 07:46:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F2816E3B7; Mon, 5 Mar 2018 07:46:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 2659 seconds by postgrey-1.36 at gabe; Mon, 05 Mar 2018 07:46:06 UTC Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6367D6E3B7 for ; Mon, 5 Mar 2018 07:46:06 +0000 (UTC) Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.156]) by regular1.263xmail.com (Postfix) with ESMTP id EBB084AA0; Mon, 5 Mar 2018 15:46:01 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 99FBF3D9; Mon, 5 Mar 2018 15:45:58 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 38113455Y3; Mon, 05 Mar 2018 15:46:02 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org Subject: [PATCH] drm/bridge/synopsys: dw-hdmi: Fix memleak in __dw_hdmi_remove Date: Mon, 5 Mar 2018 15:45:55 +0800 Message-Id: <20180305074555.23368-1-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jose Abreu , Neil Armstrong , David Airlie , Jeffy Chen , Jernej Skrabec , dri-devel@lists.freedesktop.org, Hans Verkuil , Russell King , Laurent Pinchart , Romain Perier MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The platform_device_register_full() will allocate dma_mask for hdmi->audio, so we should free before platform_device_unregister(). Reported by kmemleak: unreferenced object 0xffffffc0ef70ff00 (size 128): comm "kworker/4:1", pid 123, jiffies 4294670080 (age 189.604s) hex dump (first 32 bytes): ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<0000000021946f44>] kmemleak_alloc+0x58/0x8c [<000000009c43890d>] kmem_cache_alloc_memcg_trace+0x18c/0x25c [<000000000e17cd06>] platform_device_register_full+0x64/0x108 [<00000000418a0882>] __dw_hdmi_probe+0xb9c/0xcc0 [<00000000e0b720fd>] dw_hdmi_bind+0x30/0x88 [<000000009af347f6>] dw_hdmi_rockchip_bind+0x260/0x2e8 Signed-off-by: Jeffy Chen --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index f9802399cc0d..d9afdc59d4f4 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -2567,8 +2567,10 @@ __dw_hdmi_probe(struct platform_device *pdev, static void __dw_hdmi_remove(struct dw_hdmi *hdmi) { - if (hdmi->audio && !IS_ERR(hdmi->audio)) + if (hdmi->audio && !IS_ERR(hdmi->audio)) { + kfree(hdmi->audio->dev.dma_mask); platform_device_unregister(hdmi->audio); + } if (!IS_ERR(hdmi->cec)) platform_device_unregister(hdmi->cec);