Re: [PATCH] drm/amd/display: Fix memory leak in dm_sw_fini()
Applied. Thanks! On Mon, Feb 12, 2024 at 8:08 PM Armin Wolf wrote: > > After destroying dmub_srv, the memory associated with it is > not freed, causing a memory leak: > > unreferenced object 0x896302b45800 (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(+) > > 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 >
[PATCH] drm/amd/display: Fix memory leak in dm_sw_fini()
After destroying dmub_srv, the memory associated with it is not freed, causing a memory leak: unreferenced object 0x896302b45800 (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(+) 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
Re: [PATCH] drm/amd/display: Fix memory leak in dm_set_writeback()
Thanks for catching this. Reviewed-by: Alex Hung On 2023-12-08 02:58, Harshit Mogalapalli wrote: 'wb_info' needs to be freed on error paths or it would leak the memory. Smatch pointed this out. Fixes: c81e13b929df ("drm/amd/display: Hande writeback request from userspace") Signed-off-by: Harshit Mogalapalli --- This is based on static analysis and only compile tested --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 ++ 1 file changed, 2 insertions(+) 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 afdcc43ea06c..333995f70239 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -8871,12 +8871,14 @@ static void dm_set_writeback(struct amdgpu_display_manager *dm, acrtc = to_amdgpu_crtc(wb_conn->encoder.crtc); if (!acrtc) { DRM_ERROR("no amdgpu_crtc found\n"); + kfree(wb_info); return; } afb = to_amdgpu_framebuffer(new_con_state->writeback_job->fb); if (!afb) { DRM_ERROR("No amdgpu_framebuffer found\n"); + kfree(wb_info); return; }
[PATCH] drm/amd/display: Fix memory leak in dm_set_writeback()
'wb_info' needs to be freed on error paths or it would leak the memory. Smatch pointed this out. Fixes: c81e13b929df ("drm/amd/display: Hande writeback request from userspace") Signed-off-by: Harshit Mogalapalli --- This is based on static analysis and only compile tested --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 ++ 1 file changed, 2 insertions(+) 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 afdcc43ea06c..333995f70239 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -8871,12 +8871,14 @@ static void dm_set_writeback(struct amdgpu_display_manager *dm, acrtc = to_amdgpu_crtc(wb_conn->encoder.crtc); if (!acrtc) { DRM_ERROR("no amdgpu_crtc found\n"); + kfree(wb_info); return; } afb = to_amdgpu_framebuffer(new_con_state->writeback_job->fb); if (!afb) { DRM_ERROR("No amdgpu_framebuffer found\n"); + kfree(wb_info); return; } -- 2.39.3
Patch "drm/amd/display: fix memory leak when using debugfs_lookup()" has been added to the 5.19-stable tree
This is a note to let you know that I've just added the patch titled drm/amd/display: fix memory leak when using debugfs_lookup() to the 5.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drm-amd-display-fix-memory-leak-when-using-debugfs_lookup.patch and it can be found in the queue-5.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From cbfac7fa491651c57926c99edeb7495c6c1aeac2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Sep 2022 15:01:05 +0200 Subject: drm/amd/display: fix memory leak when using debugfs_lookup() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman commit cbfac7fa491651c57926c99edeb7495c6c1aeac2 upstream. When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up by properly calling dput(). Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: Alex Deucher Cc: "Christian König" Cc: "Pan, Xinhui" Cc: David Airlie Cc: Daniel Vetter Cc: Wayne Lin Cc: hersen wu Cc: Wenjing Liu Cc: Patrik Jakobsson Cc: Thelford Williams Cc: Fangzhi Zuo Cc: Yongzhi Liu Cc: Mikita Lipski Cc: Jiapeng Chong Cc: Bhanuprakash Modem Cc: Sean Paul Cc: amd-...@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Cc: sta...@vger.kernel.org Reviewed-by: Rodrigo Siqueira Signed-off-by: Greg Kroah-Hartman Signed-off-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c @@ -3188,7 +3188,7 @@ void crtc_debugfs_init(struct drm_crtc * &crc_win_y_end_fops); debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc, &crc_win_update_fops); - + dput(dir); } #endif /* Patches currently in stable-queue which might be from gre...@linuxfoundation.org are queue-5.19/alsa-aloop-fix-random-zeros-in-capture-data-when-using-jiffies-timer.patch queue-5.19/driver-core-fix-driver_set_override-issue-with-empty-strings.patch queue-5.19/alsa-usb-audio-split-endpoint-setups-for-hw_params-and-prepare.patch queue-5.19/soc-fsl-select-fsl_guts-driver-for-dpio.patch queue-5.19/fs-only-do-a-memory-barrier-for-the-first-set_buffer_uptodate.patch queue-5.19/tracefs-only-clobber-mode-uid-gid-on-remount-if-asked.patch queue-5.19/efi-capsule-loader-fix-use-after-free-in-efi_capsule_write.patch queue-5.19/alsa-emu10k1-fix-out-of-bounds-access-in-snd_emu10k1_pcm_channel_alloc.patch queue-5.19/net-mvpp2-debugfs-fix-memory-leak-when-using-debugfs_lookup.patch queue-5.19/efi-libstub-disable-struct-randomization.patch queue-5.19/revert-mm-kmemleak-take-a-full-lowmem-check-in-kmemleak_-_phys.patch queue-5.19/sched-debug-fix-dentry-leak-in-update_sched_domain_debugfs.patch queue-5.19/alsa-usb-audio-fix-an-out-of-bounds-bug-in-__snd_usb_parse_audio_interface.patch queue-5.19/kprobes-prohibit-probes-in-gate-area.patch queue-5.19/tracing-hold-caller_addr-to-hardirq_-enable-disable-_ip.patch queue-5.19/wifi-iwlegacy-4965-corrected-fix-for-potential-off-by-one-overflow-in-il4965_rs_fill_link_cmd.patch queue-5.19/alsa-pcm-oss-fix-race-at-sndctl_dsp_sync.patch queue-5.19/perf-risc-v-fix-access-beyond-allocated-array.patch queue-5.19/debugfs-add-debugfs_lookup_and_remove.patch queue-5.19/wifi-mt76-mt7921e-fix-crash-in-chip-reset-fail.patch queue-5.19/btrfs-zoned-fix-api-misuse-of-zone-finish-waiting.patch queue-5.19/vfio-type1-unpin-zero-pages.patch queue-5.19/tracing-fix-to-check-event_mutex-is-held-while-accessing-trigger-list.patch queue-5.19/alsa-hda-once-again-fix-regression-of-page-allocations-with-iommu.patch queue-5.19/btrfs-zoned-set-pseudo-max-append-zone-limit-in-zone-emulation-mode.patch queue-5.19/drm-amd-display-fix-memory-leak-when-using-debugfs_lookup.patch queue-5.19/alsa-usb-audio-clear-fixed-clock-rate-at-closing-ep.patch
Patch "drm/amd/display: fix memory leak when using debugfs_lookup()" has been added to the 5.15-stable tree
This is a note to let you know that I've just added the patch titled drm/amd/display: fix memory leak when using debugfs_lookup() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drm-amd-display-fix-memory-leak-when-using-debugfs_lookup.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From cbfac7fa491651c57926c99edeb7495c6c1aeac2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Sep 2022 15:01:05 +0200 Subject: drm/amd/display: fix memory leak when using debugfs_lookup() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman commit cbfac7fa491651c57926c99edeb7495c6c1aeac2 upstream. When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up by properly calling dput(). Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: Alex Deucher Cc: "Christian König" Cc: "Pan, Xinhui" Cc: David Airlie Cc: Daniel Vetter Cc: Wayne Lin Cc: hersen wu Cc: Wenjing Liu Cc: Patrik Jakobsson Cc: Thelford Williams Cc: Fangzhi Zuo Cc: Yongzhi Liu Cc: Mikita Lipski Cc: Jiapeng Chong Cc: Bhanuprakash Modem Cc: Sean Paul Cc: amd-...@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Cc: sta...@vger.kernel.org Reviewed-by: Rodrigo Siqueira Signed-off-by: Greg Kroah-Hartman Signed-off-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c @@ -3007,7 +3007,7 @@ void crtc_debugfs_init(struct drm_crtc * &crc_win_y_end_fops); debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc, &crc_win_update_fops); - + dput(dir); } #endif /* Patches currently in stable-queue which might be from gre...@linuxfoundation.org are queue-5.15/alsa-aloop-fix-random-zeros-in-capture-data-when-using-jiffies-timer.patch queue-5.15/alsa-usb-audio-split-endpoint-setups-for-hw_params-and-prepare.patch queue-5.15/net-wwan-iosm-remove-pointless-null-check.patch queue-5.15/fs-only-do-a-memory-barrier-for-the-first-set_buffer_uptodate.patch queue-5.15/efi-capsule-loader-fix-use-after-free-in-efi_capsule_write.patch queue-5.15/alsa-emu10k1-fix-out-of-bounds-access-in-snd_emu10k1_pcm_channel_alloc.patch queue-5.15/net-mvpp2-debugfs-fix-memory-leak-when-using-debugfs_lookup.patch queue-5.15/efi-libstub-disable-struct-randomization.patch queue-5.15/revert-mm-kmemleak-take-a-full-lowmem-check-in-kmemleak_-_phys.patch queue-5.15/sched-debug-fix-dentry-leak-in-update_sched_domain_debugfs.patch queue-5.15/alsa-usb-audio-fix-an-out-of-bounds-bug-in-__snd_usb_parse_audio_interface.patch queue-5.15/kprobes-prohibit-probes-in-gate-area.patch queue-5.15/wifi-iwlegacy-4965-corrected-fix-for-potential-off-by-one-overflow-in-il4965_rs_fill_link_cmd.patch queue-5.15/alsa-pcm-oss-fix-race-at-sndctl_dsp_sync.patch queue-5.15/debugfs-add-debugfs_lookup_and_remove.patch queue-5.15/vfio-type1-unpin-zero-pages.patch queue-5.15/tracing-fix-to-check-event_mutex-is-held-while-accessing-trigger-list.patch queue-5.15/btrfs-zoned-set-pseudo-max-append-zone-limit-in-zone-emulation-mode.patch queue-5.15/drm-amd-display-fix-memory-leak-when-using-debugfs_lookup.patch
Re: [PATCH] drm/amd/display: fix memory leak when using debugfs_lookup()
On Tue, Sep 06, 2022 at 11:39:44AM -0400, Rodrigo Siqueira Jordao wrote: > > > On 2022-09-06 11:06, Greg Kroah-Hartman wrote: > > On Tue, Sep 06, 2022 at 10:52:28AM -0400, Rodrigo Siqueira Jordao wrote: > > > > > > > > > On 2022-09-02 09:10, Greg Kroah-Hartman wrote: > > > > On Fri, Sep 02, 2022 at 03:01:05PM +0200, Greg Kroah-Hartman wrote: > > > > > When calling debugfs_lookup() the result must have dput() called on > > > > > it, > > > > > otherwise the memory will leak over time. Fix this up by properly > > > > > calling dput(). > > > > > > > > > > Cc: Harry Wentland > > > > > Cc: Leo Li > > > > > Cc: Rodrigo Siqueira > > > > > Cc: Alex Deucher > > > > > Cc: "Christian König" > > > > > Cc: "Pan, Xinhui" > > > > > Cc: David Airlie > > > > > Cc: Daniel Vetter > > > > > Cc: Wayne Lin > > > > > Cc: hersen wu > > > > > Cc: Wenjing Liu > > > > > Cc: Patrik Jakobsson > > > > > Cc: Thelford Williams > > > > > Cc: Fangzhi Zuo > > > > > Cc: Yongzhi Liu > > > > > Cc: Mikita Lipski > > > > > Cc: Jiapeng Chong > > > > > Cc: Bhanuprakash Modem > > > > > Cc: Sean Paul > > > > > Cc: amd-...@lists.freedesktop.org > > > > > Cc: dri-devel@lists.freedesktop.org > > > > > Signed-off-by: Greg Kroah-Hartman > > > > > --- > > > > > > > > Despite a zillion cc: items, I forgot to cc: stable on this. Can the > > > > maintainer add that here, or do you all want me to resend it with that > > > > item added? > > > > > > > > thanks, > > > > > > > > greg k-h > > > > > > Hi Greg, > > > > > > Reviewed-by: Rodrigo Siqueira > > > > > > Is 'Cc: sta...@vger.kernel.org' enough here? I can make this change > > > before I > > > merge it into amd-staging-drm-next. > > > > Yes, please add the cc: stable@ line to the body of the patch, sorry I > > forgot that. > > > > Change applied to amd-staging-drm-next, with the Cc to the stable branch. Wonderful, thanks!
Re: [PATCH] drm/amd/display: fix memory leak when using debugfs_lookup()
On 2022-09-06 11:06, Greg Kroah-Hartman wrote: On Tue, Sep 06, 2022 at 10:52:28AM -0400, Rodrigo Siqueira Jordao wrote: On 2022-09-02 09:10, Greg Kroah-Hartman wrote: On Fri, Sep 02, 2022 at 03:01:05PM +0200, Greg Kroah-Hartman wrote: When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up by properly calling dput(). Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: Alex Deucher Cc: "Christian König" Cc: "Pan, Xinhui" Cc: David Airlie Cc: Daniel Vetter Cc: Wayne Lin Cc: hersen wu Cc: Wenjing Liu Cc: Patrik Jakobsson Cc: Thelford Williams Cc: Fangzhi Zuo Cc: Yongzhi Liu Cc: Mikita Lipski Cc: Jiapeng Chong Cc: Bhanuprakash Modem Cc: Sean Paul Cc: amd-...@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman --- Despite a zillion cc: items, I forgot to cc: stable on this. Can the maintainer add that here, or do you all want me to resend it with that item added? thanks, greg k-h Hi Greg, Reviewed-by: Rodrigo Siqueira Is 'Cc: sta...@vger.kernel.org' enough here? I can make this change before I merge it into amd-staging-drm-next. Yes, please add the cc: stable@ line to the body of the patch, sorry I forgot that. Change applied to amd-staging-drm-next, with the Cc to the stable branch. Thanks Siqueira thanks, greg k-h
Re: [PATCH] drm/amd/display: fix memory leak when using debugfs_lookup()
On Tue, Sep 06, 2022 at 10:52:28AM -0400, Rodrigo Siqueira Jordao wrote: > > > On 2022-09-02 09:10, Greg Kroah-Hartman wrote: > > On Fri, Sep 02, 2022 at 03:01:05PM +0200, Greg Kroah-Hartman wrote: > > > When calling debugfs_lookup() the result must have dput() called on it, > > > otherwise the memory will leak over time. Fix this up by properly > > > calling dput(). > > > > > > Cc: Harry Wentland > > > Cc: Leo Li > > > Cc: Rodrigo Siqueira > > > Cc: Alex Deucher > > > Cc: "Christian König" > > > Cc: "Pan, Xinhui" > > > Cc: David Airlie > > > Cc: Daniel Vetter > > > Cc: Wayne Lin > > > Cc: hersen wu > > > Cc: Wenjing Liu > > > Cc: Patrik Jakobsson > > > Cc: Thelford Williams > > > Cc: Fangzhi Zuo > > > Cc: Yongzhi Liu > > > Cc: Mikita Lipski > > > Cc: Jiapeng Chong > > > Cc: Bhanuprakash Modem > > > Cc: Sean Paul > > > Cc: amd-...@lists.freedesktop.org > > > Cc: dri-devel@lists.freedesktop.org > > > Signed-off-by: Greg Kroah-Hartman > > > --- > > > > Despite a zillion cc: items, I forgot to cc: stable on this. Can the > > maintainer add that here, or do you all want me to resend it with that > > item added? > > > > thanks, > > > > greg k-h > > Hi Greg, > > Reviewed-by: Rodrigo Siqueira > > Is 'Cc: sta...@vger.kernel.org' enough here? I can make this change before I > merge it into amd-staging-drm-next. Yes, please add the cc: stable@ line to the body of the patch, sorry I forgot that. thanks, greg k-h
Re: [PATCH] drm/amd/display: fix memory leak when using debugfs_lookup()
On 2022-09-02 09:10, Greg Kroah-Hartman wrote: On Fri, Sep 02, 2022 at 03:01:05PM +0200, Greg Kroah-Hartman wrote: When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up by properly calling dput(). Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: Alex Deucher Cc: "Christian König" Cc: "Pan, Xinhui" Cc: David Airlie Cc: Daniel Vetter Cc: Wayne Lin Cc: hersen wu Cc: Wenjing Liu Cc: Patrik Jakobsson Cc: Thelford Williams Cc: Fangzhi Zuo Cc: Yongzhi Liu Cc: Mikita Lipski Cc: Jiapeng Chong Cc: Bhanuprakash Modem Cc: Sean Paul Cc: amd-...@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman --- Despite a zillion cc: items, I forgot to cc: stable on this. Can the maintainer add that here, or do you all want me to resend it with that item added? thanks, greg k-h Hi Greg, Reviewed-by: Rodrigo Siqueira Is 'Cc: sta...@vger.kernel.org' enough here? I can make this change before I merge it into amd-staging-drm-next. Thanks Siqueira
Re: [PATCH] drm/amd/display: fix memory leak when using debugfs_lookup()
On Fri, Sep 02, 2022 at 03:01:05PM +0200, Greg Kroah-Hartman wrote: > When calling debugfs_lookup() the result must have dput() called on it, > otherwise the memory will leak over time. Fix this up by properly > calling dput(). > > Cc: Harry Wentland > Cc: Leo Li > Cc: Rodrigo Siqueira > Cc: Alex Deucher > Cc: "Christian König" > Cc: "Pan, Xinhui" > Cc: David Airlie > Cc: Daniel Vetter > Cc: Wayne Lin > Cc: hersen wu > Cc: Wenjing Liu > Cc: Patrik Jakobsson > Cc: Thelford Williams > Cc: Fangzhi Zuo > Cc: Yongzhi Liu > Cc: Mikita Lipski > Cc: Jiapeng Chong > Cc: Bhanuprakash Modem > Cc: Sean Paul > Cc: amd-...@lists.freedesktop.org > Cc: dri-devel@lists.freedesktop.org > Signed-off-by: Greg Kroah-Hartman > --- Despite a zillion cc: items, I forgot to cc: stable on this. Can the maintainer add that here, or do you all want me to resend it with that item added? thanks, greg k-h
[PATCH] drm/amd/display: fix memory leak when using debugfs_lookup()
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up by properly calling dput(). Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: Alex Deucher Cc: "Christian König" Cc: "Pan, Xinhui" Cc: David Airlie Cc: Daniel Vetter Cc: Wayne Lin Cc: hersen wu Cc: Wenjing Liu Cc: Patrik Jakobsson Cc: Thelford Williams Cc: Fangzhi Zuo Cc: Yongzhi Liu Cc: Mikita Lipski Cc: Jiapeng Chong Cc: Bhanuprakash Modem Cc: Sean Paul Cc: amd-...@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c index 0e48824f55e3..ee242d9d8b06 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c @@ -3288,6 +3288,7 @@ void crtc_debugfs_init(struct drm_crtc *crtc) &crc_win_y_end_fops); debugfs_create_file_unsafe("crc_win_update", 0644, dir, crtc, &crc_win_update_fops); + dput(dir); #endif debugfs_create_file("amdgpu_current_bpc", 0644, crtc->debugfs_entry, crtc, &amdgpu_current_bpc_fops); -- 2.37.3
Re: [PATCH] drm/amd/display: Fix memory leak in dcn21_clock_source_create
Applied. Thanks! Alex On Thu, Apr 21, 2022 at 5:03 AM Miaoqian Lin wrote: > > When dcn20_clk_src_construct() fails, we need to release clk_src. > > Fixes: 6f4e6361c3ff ("drm/amd/display: Add Renoir resource (v2)") > Signed-off-by: Miaoqian Lin > --- > drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c > b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c > index 3fe4bfbb98a0..faab59508d82 100644 > --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c > +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c > @@ -997,6 +997,7 @@ static struct clock_source *dcn21_clock_source_create( > return &clk_src->base; > } > > + kfree(clk_src); > BREAK_TO_DEBUGGER(); > return NULL; > } > -- > 2.17.1 >
[PATCH] drm/amd/display: Fix memory leak in dcn21_clock_source_create
When dcn20_clk_src_construct() fails, we need to release clk_src. Fixes: 6f4e6361c3ff ("drm/amd/display: Add Renoir resource (v2)") Signed-off-by: Miaoqian Lin --- drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c index 3fe4bfbb98a0..faab59508d82 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c @@ -997,6 +997,7 @@ static struct clock_source *dcn21_clock_source_create( return &clk_src->base; } + kfree(clk_src); BREAK_TO_DEBUGGER(); return NULL; } -- 2.17.1
Re: [PATCH] drm/amd/display: Fix memory leak
[Public] Applied. Thanks! From: Wentland, Harry Sent: Friday, January 21, 2022 2:03 PM To: Yongzhi Liu ; Li, Sun peng (Leo) ; Siqueira, Rodrigo ; Deucher, Alexander ; Koenig, Christian ; Pan, Xinhui ; airl...@linux.ie ; dan...@ffwll.ch ; Lipski, Mikita ; Lin, Wayne ; Kazlauskas, Nicholas ; Zuo, Jerry ; anson.ja...@amd.com ; eryk.b...@amd.com ; Pillai, Aurabindo ; Das, Nirmoy Cc: amd-...@lists.freedesktop.org ; dri-devel@lists.freedesktop.org ; linux-ker...@vger.kernel.org Subject: Re: [PATCH] drm/amd/display: Fix memory leak On 2022-01-21 06:26, Yongzhi Liu wrote: > [why] > Resource release is needed on the error handling path > to prevent memory leak. > > [how] > Fix this by adding kfree on the error handling path. > > Signed-off-by: Yongzhi Liu Reviewed-by: Harry Wentland Harry > --- > .../drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 80 > -- > 1 file changed, 60 insertions(+), 20 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > index ded64d0..e463d46 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > @@ -227,8 +227,10 @@ static ssize_t dp_link_settings_read(struct file *f, > char __user *buf, >break; > >r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); >return r; /* r = -EFAULT */ > + } > >buf += 1; >size -= 1; > @@ -389,8 +391,10 @@ static ssize_t dp_phy_settings_read(struct file *f, char > __user *buf, >break; > >r = put_user((*(rd_buf + result)), buf); > - if (r) > + if (r) { > + kfree(rd_buf); >return r; /* r = -EFAULT */ > + } > >buf += 1; >size -= 1; > @@ -1359,8 +1363,10 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, > char __user *buf, >break; >} > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); >return -ENXIO; > + } > >dsc = pipe_ctx->stream_res.dsc; >if (dsc) > @@ -1376,8 +1382,10 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, > char __user *buf, >break; > >r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); >return r; /* r = -EFAULT */ > + } > >buf += 1; >size -= 1; > @@ -1546,8 +1554,10 @@ static ssize_t dp_dsc_slice_width_read(struct file *f, > char __user *buf, >break; >} > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); >return -ENXIO; > + } > >dsc = pipe_ctx->stream_res.dsc; >if (dsc) > @@ -1563,8 +1573,10 @@ static ssize_t dp_dsc_slice_width_read(struct file *f, > char __user *buf, >break; > >r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); >return r; /* r = -EFAULT */ > + } > >buf += 1; >size -= 1; > @@ -1731,8 +1743,10 @@ static ssize_t dp_dsc_slice_height_read(struct file > *f, char __user *buf, >break; >} > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); >return -ENXIO; > + } > >dsc = pipe_ctx->stream_res.dsc; >if (dsc) > @@ -1748,8 +1762,10 @@ static ssize_t dp_dsc_slice_height_read(struct file > *f, char __user *buf, >break; > >r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); >return r; /* r = -EFAULT */ > + } > >buf += 1; >size -= 1; > @@ -1912,8 +1928,10 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct file > *f, char __user *buf, >break; >} > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); >return -ENXIO;
Re: [PATCH] drm/amd/display: Fix memory leak
On 2022-01-21 06:26, Yongzhi Liu wrote: > [why] > Resource release is needed on the error handling path > to prevent memory leak. > > [how] > Fix this by adding kfree on the error handling path. > > Signed-off-by: Yongzhi Liu Reviewed-by: Harry Wentland Harry > --- > .../drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 80 > -- > 1 file changed, 60 insertions(+), 20 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > index ded64d0..e463d46 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c > @@ -227,8 +227,10 @@ static ssize_t dp_link_settings_read(struct file *f, > char __user *buf, > break; > > r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); > return r; /* r = -EFAULT */ > + } > > buf += 1; > size -= 1; > @@ -389,8 +391,10 @@ static ssize_t dp_phy_settings_read(struct file *f, char > __user *buf, > break; > > r = put_user((*(rd_buf + result)), buf); > - if (r) > + if (r) { > + kfree(rd_buf); > return r; /* r = -EFAULT */ > + } > > buf += 1; > size -= 1; > @@ -1359,8 +1363,10 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, > char __user *buf, > break; > } > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); > return -ENXIO; > + } > > dsc = pipe_ctx->stream_res.dsc; > if (dsc) > @@ -1376,8 +1382,10 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, > char __user *buf, > break; > > r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); > return r; /* r = -EFAULT */ > + } > > buf += 1; > size -= 1; > @@ -1546,8 +1554,10 @@ static ssize_t dp_dsc_slice_width_read(struct file *f, > char __user *buf, > break; > } > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); > return -ENXIO; > + } > > dsc = pipe_ctx->stream_res.dsc; > if (dsc) > @@ -1563,8 +1573,10 @@ static ssize_t dp_dsc_slice_width_read(struct file *f, > char __user *buf, > break; > > r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); > return r; /* r = -EFAULT */ > + } > > buf += 1; > size -= 1; > @@ -1731,8 +1743,10 @@ static ssize_t dp_dsc_slice_height_read(struct file > *f, char __user *buf, > break; > } > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); > return -ENXIO; > + } > > dsc = pipe_ctx->stream_res.dsc; > if (dsc) > @@ -1748,8 +1762,10 @@ static ssize_t dp_dsc_slice_height_read(struct file > *f, char __user *buf, > break; > > r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); > return r; /* r = -EFAULT */ > + } > > buf += 1; > size -= 1; > @@ -1912,8 +1928,10 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct file > *f, char __user *buf, > break; > } > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); > return -ENXIO; > + } > > dsc = pipe_ctx->stream_res.dsc; > if (dsc) > @@ -1929,8 +1947,10 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct file > *f, char __user *buf, > break; > > r = put_user(*(rd_buf + result), buf); > - if (r) > + if (r) { > + kfree(rd_buf); > return r; /* r = -EFAULT */ > + } > > buf += 1; > size -= 1; > @@ -2088,8 +2108,10 @@ static ssize_t dp_dsc_pic_width_read(struct file *f, > char __user *buf, > break; > } > > - if (!pipe_ctx) > + if (!pipe_ctx) { > + kfree(rd_buf); > return -ENXIO; > + } > > dsc = pipe_ctx->stream_res.dsc; > if (dsc) > @@ -2105,8 +2127,10 @@ static ssize_t dp_dsc_pic_width_read(struct file *f, > char __user *buf, > break; > > r = put_user(*(rd_buf + result), buf)
[PATCH] drm/amd/display: Fix memory leak
[why] Resource release is needed on the error handling path to prevent memory leak. [how] Fix this by adding kfree on the error handling path. Signed-off-by: Yongzhi Liu --- .../drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 80 -- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c index ded64d0..e463d46 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c @@ -227,8 +227,10 @@ static ssize_t dp_link_settings_read(struct file *f, char __user *buf, break; r = put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r = -EFAULT */ + } buf += 1; size -= 1; @@ -389,8 +391,10 @@ static ssize_t dp_phy_settings_read(struct file *f, char __user *buf, break; r = put_user((*(rd_buf + result)), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r = -EFAULT */ + } buf += 1; size -= 1; @@ -1359,8 +1363,10 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf, break; } - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } dsc = pipe_ctx->stream_res.dsc; if (dsc) @@ -1376,8 +1382,10 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf, break; r = put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r = -EFAULT */ + } buf += 1; size -= 1; @@ -1546,8 +1554,10 @@ static ssize_t dp_dsc_slice_width_read(struct file *f, char __user *buf, break; } - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } dsc = pipe_ctx->stream_res.dsc; if (dsc) @@ -1563,8 +1573,10 @@ static ssize_t dp_dsc_slice_width_read(struct file *f, char __user *buf, break; r = put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r = -EFAULT */ + } buf += 1; size -= 1; @@ -1731,8 +1743,10 @@ static ssize_t dp_dsc_slice_height_read(struct file *f, char __user *buf, break; } - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } dsc = pipe_ctx->stream_res.dsc; if (dsc) @@ -1748,8 +1762,10 @@ static ssize_t dp_dsc_slice_height_read(struct file *f, char __user *buf, break; r = put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r = -EFAULT */ + } buf += 1; size -= 1; @@ -1912,8 +1928,10 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct file *f, char __user *buf, break; } - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } dsc = pipe_ctx->stream_res.dsc; if (dsc) @@ -1929,8 +1947,10 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct file *f, char __user *buf, break; r = put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r = -EFAULT */ + } buf += 1; size -= 1; @@ -2088,8 +2108,10 @@ static ssize_t dp_dsc_pic_width_read(struct file *f, char __user *buf, break; } - if (!pipe_ctx) + if (!pipe_ctx) { + kfree(rd_buf); return -ENXIO; + } dsc = pipe_ctx->stream_res.dsc; if (dsc) @@ -2105,8 +2127,10 @@ static ssize_t dp_dsc_pic_width_read(struct file *f, char __user *buf, break; r = put_user(*(rd_buf + result), buf); - if (r) + if (r) { + kfree(rd_buf); return r; /* r = -EFAULT */ + } buf += 1; size -
Re: [PATCH] drm/amd/display: Fix memory leak in amdgpu_dm_mode_config_init()
> When amdgpu_display_modeset_create_props() fails, state and > state->context should be freed to prevent memleak. It's the > same when amdgpu_dm_audio_init() fails. * Can another imperative wording become helpful for the change description? * Would you like to consider the tag “Fixes” for the commit message? https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c?id=08572451b4b1783fdff787b0188c4d50fdf96b81 … > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -2834,12 +2834,18 @@ static int amdgpu_dm_mode_config_init(struct > amdgpu_device *adev) > &dm_atomic_state_funcs); > > r = amdgpu_display_modeset_create_props(adev); > - if (r) > + if (r) { > + dc_release_state(state->context); > + kfree(state); > return r; > + } > > r = amdgpu_dm_audio_init(adev); > - if (r) > + if (r) { > + dc_release_state(state->context); > + kfree(state); > return r; > + } > > return 0; > } I imagine that the exception handling code can be improved another bit for this function implementation. How do you think about to avoid such duplicate source code? https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=15bc20c6af4ceee97a1f90b43c0e386643c071b4#n475 Regards, Markus ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel