Received: by 10.223.185.116 with SMTP id b49csp2298004wrg; Sun, 4 Mar 2018 23:47:39 -0800 (PST) X-Google-Smtp-Source: AG47ELvaDfauNtyjwhsxXKznWlpemaVcFrXGwzoG7b1ZMJfV5nuwdOnDSfIxCgshsZi3mnYfxM7x X-Received: by 10.99.124.14 with SMTP id x14mr11508955pgc.290.1520236059281; Sun, 04 Mar 2018 23:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520236059; cv=none; d=google.com; s=arc-20160816; b=x8pJcitY0m8YU8CNetLjsJvs7zwy3pIGL6A+ArnH6Xz3rcc9mQh9+y5wkt/4Ls1Rzr tzLofVig+9MCvPRPCrSn/btxjCAkPGw8jkJkaDF+YwGkBpxz+IRTWUCjEhl9yuI0tTUb m4m0k7q4+l79KjH8f3n2vMKSDYIzcKVHV73bXqQ7VkFDEZdyVBtsf3/zX9QR60AsrLe3 PDdNUIRbQJiOxdNSGbzVEoUCfMP8PuRJusJjExqKBBjYA7We7EAEeWhGYelAZv8UrtYH c9O5JHx96uttbGPsRQ3mGQuabQjNZQkpQMNEOC2oCeGUBzMCWhKvSKUZuxJ9PLJA/pu7 PdEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=eTJmmU01fQl+2JOseXcGAzAusllV4cQKBi4H+BOx7yk=; b=q35TYg4uDWzTjsnq1ESUzOji4At7ZbTANzgedZXE4feymqUGsCdoFC3NcHwwJE6ukq G+J7mUxlof+7HV/95zwKAR9skwAVV/FE8MQFNkLIk+8DqtokL9EmQiqLdULS6qXMn4ft j8EA2CpNiHs+bOdIsVzPa7yoVTjTz4UhGkfulKq88uJ0Fhmnlx1Fy+kBAKI8fQ77kYM1 j1VVA0kPmhB8BtJhDygIL4K4LdnV+JHbxOTUUX+k6dAHzw+fFP3hGocv6w3cdRUegoOl wS8KCzhu8BvH1fPXSyS6Kdex3Kx6c3OSqHNtFWDSZaaZPzP/vEfrzbPmzn6wsXen2e9c mt+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p184si8058880pga.700.2018.03.04.23.47.24; Sun, 04 Mar 2018 23:47:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933098AbeCEHqR (ORCPT + 99 others); Mon, 5 Mar 2018 02:46:17 -0500 Received: from regular1.263xmail.com ([211.150.99.140]:53606 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932892AbeCEHqO (ORCPT ); Mon, 5 Mar 2018 02:46:14 -0500 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 Cc: Jeffy Chen , Andrzej Hajda , Romain Perier , Archit Taneja , dri-devel@lists.freedesktop.org, Russell King , Neil Armstrong , David Airlie , Hans Verkuil , Jose Abreu , Jernej Skrabec , Laurent Pinchart 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.11.0