mirror_ubuntu-kernels/drivers/gpu/drm/mediatek
Chen-Yu Tsai dcc583c225 drm/mediatek: Correctly free sg_table in gem prime vmap
The MediaTek DRM driver implements GEM PRIME vmap by fetching the
sg_table for the object, iterating through the pages, and then
vmapping them. In essence, unlike the GEM DMA helpers which vmap
when the object is first created or imported, the MediaTek version
does it on request.

Unfortunately, the code never correctly frees the sg_table contents.
This results in a kernel memory leak. On a Hayato device with a text
console on the internal display, this results in the system running
out of memory in a few days from all the console screen cursor updates.

Add sg_free_table() to correctly free the contents of the sg_table. This
was missing despite explicitly required by mtk_gem_prime_get_sg_table().

Also move the "out" shortcut label to after the kfree() call for the
sg_table. Having sg_free_table() together with kfree() makes more sense.
The shortcut is only used when the object already has a kernel address,
in which case the pointer is NULL and kfree() does nothing. Hence this
change causes no functional change.

Fixes: 3df64d7b0a ("drm/mediatek: Implement gem prime vmap/vunmap function")
Cc: <stable@vger.kernel.org>
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20231004083226.1940055-1-wenst@chromium.org/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
2023-10-16 15:44:03 +00:00
..
Kconfig drm/mediatek: dp: Add support for embedded DisplayPort aux-bus 2023-08-09 23:25:00 +00:00
Makefile drm/mediatek: Add ovl_adaptor support for MT8195 2023-03-22 16:25:16 +00:00
mtk_cec.c drm/mediatek: Convert to platform remove callback returning void 2023-08-10 23:41:55 +00:00
mtk_cec.h
mtk_disp_aal.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_disp_ccorr.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_disp_color.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_disp_drv.h drm/mediatek: Add ovl_adaptor get format function 2023-04-03 03:06:01 +00:00
mtk_disp_gamma.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_disp_merge.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_disp_ovl_adaptor.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_disp_ovl.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_disp_rdma.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_dp_reg.h drm/mediatek: dp: Remove unused register definitions 2022-09-19 12:17:42 +03:00
mtk_dp.c drm/mediatek: Convert to platform remove callback returning void 2023-08-10 23:41:55 +00:00
mtk_dpi_regs.h drm/mediatek: dpi: Add dp_intf support 2022-07-06 22:51:44 +08:00
mtk_dpi.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_drm_crtc.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_drm_crtc.h drm/mediatek: Add drm ovl_adaptor sub driver for MT8195 2023-03-22 16:45:23 +00:00
mtk_drm_ddp_comp.c drm/mediatek: Fix uninitialized symbol 2023-08-07 23:26:07 +00:00
mtk_drm_ddp_comp.h drm/mediatek: Add drm ovl_adaptor sub driver for MT8195 2023-03-22 16:45:23 +00:00
mtk_drm_drv.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_drm_drv.h drm/mediatek: Add drm ovl_adaptor sub driver for MT8195 2023-03-22 16:45:23 +00:00
mtk_drm_gem.c drm/mediatek: Correctly free sg_table in gem prime vmap 2023-10-16 15:44:03 +00:00
mtk_drm_gem.h dma-buf-map: Rename to iosys-map 2022-02-07 16:35:35 -08:00
mtk_drm_plane.c drm/mediatek: Fix dereference before null check 2023-08-10 23:50:32 +00:00
mtk_drm_plane.h drm/mediatek: Refactor pixel format logic 2023-03-12 15:03:56 +00:00
mtk_dsi.c drm/mediatek: Convert to platform remove callback returning void 2023-08-10 23:41:55 +00:00
mtk_ethdr.c drm: Explicitly include correct DT includes 2023-07-21 09:12:43 +02:00
mtk_ethdr.h drm/mediatek: Add ETHDR support for MT8195 2023-03-22 16:25:00 +00:00
mtk_hdmi_ddc.c drm/mediatek: Convert to platform remove callback returning void 2023-08-10 23:41:55 +00:00
mtk_hdmi_regs.h
mtk_hdmi.c drm/mediatek: Convert to platform remove callback returning void 2023-08-10 23:41:55 +00:00
mtk_hdmi.h drm/mediatek: Separate mtk_hdmi_phy to an independent module 2020-09-06 07:02:54 +08:00
mtk_mdp_rdma.c Mediatek DRM Next for Linux 6.6 2023-08-15 12:07:19 +10:00
mtk_mdp_rdma.h drm/mediatek: Add display MDP RDMA support for MT8195 2022-06-27 22:24:14 +08:00