From patchwork Tue Feb 13 00:50:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 200119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp265554dyb; Mon, 12 Feb 2024 17:18:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVptT7vsuZiaz4pjTsZ4FUQR8Fy11w+IpbbEbjttKzY0/PWwhshsrgTgpjKTRWEwUOHUYy8TNi8c9cAHBo9HLseFbqPRQ== X-Google-Smtp-Source: AGHT+IEVLHMdpD/uMd5vylKLijpdzpsFOR6J5LrLhij8VFxN9jtcJW1i5KmKln6EueX+wC+dkzmC X-Received: by 2002:ac8:67d0:0:b0:42c:6f1e:dff4 with SMTP id r16-20020ac867d0000000b0042c6f1edff4mr6250853qtp.7.1707787082512; Mon, 12 Feb 2024 17:18:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707787082; cv=pass; d=google.com; s=arc-20160816; b=X0KRSNNPZqfJVBbKcPgsJyJJxdAuD8jMwpCYRtj+XO5AWR9XNJasrPg5AE/JWSpFsH eli36ThQ0Uw+G+TdxTdV5IHjWekOCrAeCBVbrGG7EsA/M0eQutEsQSFd7KUO/5giURqk ppeEeo+Ui33Hb1LfZ/E5QeFa07mF25r8SeVnD8VqjD4zmRw3kU3beOvBhV6opCspHXkX mAa7tqP5eX62IcsKFBT49RRQ3AA70jHncEmtCh8atRnBNfuYatqLGI3PtTOqqsFVzsyC ba2StwpSyNF4JjezHzysYs3EjizXsGK+W2YaWkDMVFj/0RhYidqdmfFzHCyjknNVhOd9 fYKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=e+1xbpBdhT/TgFKut66jePi3l+6FOmXDMbeHkSC1EZw=; fh=OdkfbhIrH4BZSbeEUQJRmLbCyu4yDZoGVc8qw0/FzhE=; b=QR75h5JBMtvuJ8NYGi0pea07A2if9yhPitpYfhBwCmUASAnBYPzUH+JvUTivId0XOx Nluh6u/o2OnCJ9TAbPjfPaavtFJSIy04wxYErNjnK0txQb8BDcJA2HBE1wFrrmKuOMAl Mu6PZIST7qeLl7tfRN5ggNrGe/CFXWZUDslkhMqvBtDhp3Aoofo/JupEyymmmYEq7Tkq 0jhcB+3wG+MOwC+d6CAkzJvuApb+rHf6Z7/PjThiiRMoJuBe0GZ53Ss5rMZk3sxlEVcv NG8PU4BgoMbcoLQrJ8R3MzVo+YQnY1KAKUDK/RhB0RBwi2uH0klG2BSr2ue61mManm8M W6KA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=BELHSyJh; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-62774-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62774-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de X-Forwarded-Encrypted: i=2; AJvYcCVUQGHGUGxCvGVENhjMqwn0TfmEkoRoGIKRYuK13J5JDegGgpZO7p/8PR8R7krBllQ984kbMyAqxUSDM+3B6DiaBKsVEA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v15-20020ac8728f000000b0042c44dec59bsi1620159qto.482.2024.02.12.17.18.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 17:18:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62774-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=BELHSyJh; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-62774-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62774-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 513C31C24056 for ; Tue, 13 Feb 2024 01:18:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1223210FE; Tue, 13 Feb 2024 00:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="BELHSyJh" Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C43FA1DFFC for ; Tue, 13 Feb 2024 00:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785475; cv=none; b=jNI3YtU7c4dnmfINYH9+a3X18OSCGMY0ZiUsA1XaghjLvK06mm4LAIqa7NTzYh4Gu7tKskIQO1Z5lLfFKvuDZNC/ON+0QoHEmwr2HhUFDrENdUgoM4Txrs3G42YtylhOXC5E4UP2rMiB7PYUFs37KPfcedGqbOn9UubDgZWdECo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707785475; c=relaxed/simple; bh=ey7reqdyEMdyt0U+wc6isCd5i2G3QaAEjU6W+bXRcdM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=k/4Run20+/QE1lWCOH26a5Ld+glfbRohyIi+53TDIVgnw2AGKHfEsk7IWuakYjseFcvEM6nk4KV+L1/UETjeWxmtDaDDEw76/X39SXVxg/l6OdHm0p8wGPQmDGJU4KoPW9DwyQWAib/F5FzzUaS+UB2WvFAtD1iVhKlfzMN93Oc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=BELHSyJh; arc=none smtp.client-ip=212.227.15.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1707785454; x=1708390254; i=w_armin@gmx.de; bh=ey7reqdyEMdyt0U+wc6isCd5i2G3QaAEjU6W+bXRcdM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=BELHSyJhEmz3uAJ55HzjRL1FY6oYkh5fSPAP4VrjPTwQiIHWxjzBGiH7zNjhIX5M o1hL7CaND0ByRF5MC4FhkV7cuRHatvZe/wJP4N5+RQ2/TrCgqo1GAbHOBi4BgzYFj EM/J+Lc3rrUAXj+bCT1Q5OYyztmUvK/420LcOJvX/72Yi0DYFuh64G/2iS5w6ckJK NL7V1J/EiOu9wuwe3g4J/5wFss7Glpqspx4oBFayqscxnAlTGTivKqB2Qz/IY9Ldd Sngu3fskSSSRCVRd/KmthbvIgM/O7XKk1ZK6hNZwMvfZn5cLUr5yUYnZ4c0TeANaP /+qE2jxK9wf0YEJ1zw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MryT9-1rEsNn2fbh-00nvoP; Tue, 13 Feb 2024 01:50:54 +0100 From: Armin Wolf To: harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com Cc: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/amd/display: Fix memory leak in dm_sw_fini() Date: Tue, 13 Feb 2024 01:50:50 +0100 Message-Id: <20240213005050.4442-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:txK5GIP1CJKI2+qnEyUyucXhG2X+JRy/QYC3OoT7DjNOn2mydAp M5bHds0vbZWQFEiZccqvIGQ3d8NxzQxJV4kmpqIyjK2KJc5MKQLebUpgnQhoPazXAiYhRqV nYnD1BztfPyXVTHvnuc70xzX0L0mzh0UqcoRy/77BAzaf+yU0IeFE//r5PdBiaccRI9j5Hg wnM+ChIcuLfQACJilY3eg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:9GILGb7t888=;Xkv/X0SRY9RV0DtgulGZhg+N60c kXd80iCFIP+MnX0QRtvOj4FK9592oNVlPshqD5jaOXnN8jbNWNQEr/xLMEuOICuMb2fECsOLM tJ5yE0LrTqakgngNZQvPs6/9PuFOiu6thEEkvjibkrsz1ETv2wNYT3diL1B0Qj+UkTT+OLRG5 gwDl/6cT0y0aztnY6IRv/Ej9v3jAgCo6sdyrSSwGjRaDDXQz1VFwAotYPPH/LTLQ+YmgXMdhf OrrYOPkPIMZBOlQJgGzOCgJvuApzQX8vTDf95Q00lAOgffjXHTHRMzrBtyBUCfQYuuFCWA7ma F2xW+rOTNXqAMdvDEUvZRt36aMDY4TCV/+ti/LWQucxcGgjIPD1z/UebXOgjqBHyLiJL1+Rkf UyAOLsIS9PGF3Bfx42mBDd6hUDA9Xl9lS59Yqy8Tnwt4MbCAZooxrATzx5fHeqtCvSd/IKe9u qG/RBwq03VAQr7vCuzjY8bbBg0xUSe40/ztv4ucFgaT51BRPS6m1m7EbaWqFuljHGUG/rJBrd uPfSrB4I0DpPmoeGCqtlzvTBGE6/TQ31Uyd+zMelQC8BXrdJFuICXLGw8Bw+R8cr7LWO48QSu WVZWsSdl2Qv26NwrgnON5Fk33QvA+DOj0rGiaYwKmiXyBJ+/UqeC4BU5XmSJG+FtZzZ8xaoSo bEt3ytnMnqACCOjeWkyFsetBWrHPqtsBZ8X7Xte33QQk85epyVvuegcHi8s+qFH5hGkU8MHSO P14oiseodVgV23otrKGBzohb/hxBimX7xthiqndXcq1/pPIcX+PEilgJqo4t8eDp0AHjvSq+r /ZLxVojYaO7l6KnAI8ZbfUbFtDLJq2vS65vae9WW6giGA= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790744548014687051 X-GMAIL-MSGID: 1790744548014687051 After destroying dmub_srv, the memory associated with it is not freed, causing a memory leak: unreferenced object 0xffff896302b45800 (size 1024): comm "(udev-worker)", pid 222, jiffies 4294894636 hex dump (first 32 bytes): 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 00 00 00 00 ................ backtrace (crc 6265fd77): [] kmalloc_trace+0x29d/0x340 [] dm_dmub_sw_init+0xb4/0x450 [amdgpu] [] dm_sw_init+0x15/0x2b0 [amdgpu] [] amdgpu_device_init+0x1417/0x24e0 [amdgpu] [] amdgpu_driver_load_kms+0x15/0x190 [amdgpu] [] amdgpu_pci_probe+0x187/0x4e0 [amdgpu] [] local_pci_probe+0x3e/0x90 [] pci_device_probe+0xc3/0x230 [] really_probe+0xe2/0x480 [] __driver_probe_device+0x78/0x160 [] driver_probe_device+0x1f/0x90 [] __driver_attach+0xce/0x1c0 [] bus_for_each_dev+0x70/0xc0 [] bus_add_driver+0x112/0x210 [] driver_register+0x55/0x100 [] do_one_initcall+0x41/0x300 Fix this by freeing dmub_srv after destroying it. Fixes: 743b9786b14a ("drm/amd/display: Hook up the DMUB service in DM") Signed-off-by: Armin Wolf --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 + 1 file changed, 1 insertion(+) -- 2.39.2 diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 59d2eee72a32..9cbfc8d39dee 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -2287,6 +2287,7 @@ static int dm_sw_fini(void *handle) if (adev->dm.dmub_srv) { dmub_srv_destroy(adev->dm.dmub_srv); + kfree(adev->dm.dmub_srv); adev->dm.dmub_srv = NULL; }