All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Fix memory leak in dm_sw_fini()
@ 2024-02-13  0:50 Armin Wolf
  2024-02-16 16:41 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Armin Wolf @ 2024-02-13  0:50 UTC (permalink / raw)
  To: harry.wentland, sunpeng.li, Rodrigo.Siqueira
  Cc: alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel,
	amd-gfx, dri-devel, linux-kernel

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):
    [<ffffffff993495ed>] kmalloc_trace+0x29d/0x340
    [<ffffffffc0ea4a94>] dm_dmub_sw_init+0xb4/0x450 [amdgpu]
    [<ffffffffc0ea4e55>] dm_sw_init+0x15/0x2b0 [amdgpu]
    [<ffffffffc0ba8557>] amdgpu_device_init+0x1417/0x24e0 [amdgpu]
    [<ffffffffc0bab285>] amdgpu_driver_load_kms+0x15/0x190 [amdgpu]
    [<ffffffffc0ba09c7>] amdgpu_pci_probe+0x187/0x4e0 [amdgpu]
    [<ffffffff9968fd1e>] local_pci_probe+0x3e/0x90
    [<ffffffff996918a3>] pci_device_probe+0xc3/0x230
    [<ffffffff99805872>] really_probe+0xe2/0x480
    [<ffffffff99805c98>] __driver_probe_device+0x78/0x160
    [<ffffffff99805daf>] driver_probe_device+0x1f/0x90
    [<ffffffff9980601e>] __driver_attach+0xce/0x1c0
    [<ffffffff99803170>] bus_for_each_dev+0x70/0xc0
    [<ffffffff99804822>] bus_add_driver+0x112/0x210
    [<ffffffff99807245>] driver_register+0x55/0x100
    [<ffffffff990012d1>] 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 <W_Armin@gmx.de>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
 1 file changed, 1 insertion(+)

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;
 	}

--
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amd/display: Fix memory leak in dm_sw_fini()
  2024-02-13  0:50 [PATCH] drm/amd/display: Fix memory leak in dm_sw_fini() Armin Wolf
@ 2024-02-16 16:41 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2024-02-16 16:41 UTC (permalink / raw)
  To: Armin Wolf
  Cc: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, daniel, amd-gfx,
	dri-devel, linux-kernel

Applied.  Thanks!

On Mon, Feb 12, 2024 at 8:08 PM Armin Wolf <W_Armin@gmx.de> wrote:
>
> 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):
>     [<ffffffff993495ed>] kmalloc_trace+0x29d/0x340
>     [<ffffffffc0ea4a94>] dm_dmub_sw_init+0xb4/0x450 [amdgpu]
>     [<ffffffffc0ea4e55>] dm_sw_init+0x15/0x2b0 [amdgpu]
>     [<ffffffffc0ba8557>] amdgpu_device_init+0x1417/0x24e0 [amdgpu]
>     [<ffffffffc0bab285>] amdgpu_driver_load_kms+0x15/0x190 [amdgpu]
>     [<ffffffffc0ba09c7>] amdgpu_pci_probe+0x187/0x4e0 [amdgpu]
>     [<ffffffff9968fd1e>] local_pci_probe+0x3e/0x90
>     [<ffffffff996918a3>] pci_device_probe+0xc3/0x230
>     [<ffffffff99805872>] really_probe+0xe2/0x480
>     [<ffffffff99805c98>] __driver_probe_device+0x78/0x160
>     [<ffffffff99805daf>] driver_probe_device+0x1f/0x90
>     [<ffffffff9980601e>] __driver_attach+0xce/0x1c0
>     [<ffffffff99803170>] bus_for_each_dev+0x70/0xc0
>     [<ffffffff99804822>] bus_add_driver+0x112/0x210
>     [<ffffffff99807245>] driver_register+0x55/0x100
>     [<ffffffff990012d1>] 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 <W_Armin@gmx.de>
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
>  1 file changed, 1 insertion(+)
>
> 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;
>         }
>
> --
> 2.39.2
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-16 16:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13  0:50 [PATCH] drm/amd/display: Fix memory leak in dm_sw_fini() Armin Wolf
2024-02-16 16:41 ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.