From af4f896f77b30bf6811696dc86fcf61c9daf1c85 Mon Sep 17 00:00:00 2001 From: Shuicheng Lin Date: Wed, 16 Oct 2024 15:01:54 +0000 Subject: [PATCH] drm/i915/dp: Fix memory leak in parse_lfp_panel_dtd() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function parse_lfp_panel_dtd() is called when the driver attempts to initialize the eDP connector, and it allocates memory, which is recorded in panel->vbt.lfp_vbt_mode. However, since no eDP panel is connected, the driver fails at intel_edp_init_dpcd() and follows the failure path. Unfortunately, the allocated memory is not freed in this case. To fix this issue, free the memory in the failure path. leak info from kmemleak: " unreferenced object 0xffff8881252f8800 (size 128): comm "systemd-udevd", pid 192, jiffies 4294896880 hex dump (first 32 bytes): e8 fd 00 00 00 04 18 04 a0 04 40 05 00 00 00 03 ..........@..... 03 03 09 03 26 03 00 00 0a 00 00 00 00 00 00 00 ....&........... backtrace (crc 7448f6b4): [] kmemleak_alloc+0x4b/0x80 [] __kmalloc_cache_noprof+0x2be/0x390 [] intel_bios_init_panel+0x1c4c/0x2720 [xe] [] intel_bios_init_panel_early+0x13/0x20 [xe] [] intel_dp_init_connector+0x2f9/0x1080 [xe] [] intel_ddi_init+0xbba/0xf50 [xe] [] intel_bios_for_each_encoder+0x36/0x60 [xe] [] intel_setup_outputs+0x206/0x450 [xe] [] intel_display_driver_probe_nogem+0x163/0x1f0 [xe] [] xe_display_init_noaccel+0x27/0x70 [xe] [] xe_device_probe+0x806/0x9a0 [xe] [] xe_pci_probe+0x31f/0x590 [xe] [] local_pci_probe+0x48/0xb0 [] pci_device_probe+0xc8/0x280 [] really_probe+0xf8/0x390 [] __driver_probe_device+0x8a/0x170 " v2 (Jani): -use intel_bios_fini_panel() to pair with intel_bios_init_panel_early() Signed-off-by: Shuicheng Lin Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Signed-off-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20241016150154.1466131-1-shuicheng.lin@intel.com --- drivers/gpu/drm/i915/display/intel_dp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 6b27fabd61c37..7e04913bc2ffb 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -6375,6 +6375,7 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, out_vdd_off: intel_pps_vdd_off_sync(intel_dp); + intel_bios_fini_panel(&intel_connector->panel); return false; }