From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E0FBCF11C6 for ; Thu, 10 Oct 2024 10:03:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64DD210E8BC; Thu, 10 Oct 2024 10:03:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="SAi699YX"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8957F10E8BC; Thu, 10 Oct 2024 10:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728554580; x=1760090580; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=OigZHDv2iancVqONLZHNB66Bo53iQZksMm4t7h0xDHw=; b=SAi699YX7XXzfKG30kJ5FJ14QRmHHMNY5XC05xTskbtH+4f6fSOQ4FFf bGA3oLWyJnCSYPMwrTXyqs6sR3jmGPsTwqcrus5LQFnCEaj3USOtRc6UM tZ/sepTdi33EvhIp6VVlh3nPszCWLH6Oe7PZ+I9QGl1aHWe3vlJUYmzBc 4VN0tuiaqLJ0uQFvvSdcDSAPjCYVSRX8tMQD+V+PQD26H1mQxvIMlfkLc g9QZ3stQOJP+7jTjAjL+NaTfT4TYGe6ctP9Ctm4gr67StZ4TfZyqu+78g pL24GbCvyx/6EnLr9KnYPbNkYMO6Ruyu+Wq+BtWlG8PW//5gufOJOHrWU A==; X-CSE-ConnectionGUID: RiTcr/oSRkCr0IaWGnpDUw== X-CSE-MsgGUID: ciSAUhWATUSZpu/tI5AIhQ== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="39267427" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="39267427" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 03:03:00 -0700 X-CSE-ConnectionGUID: XXQf3U3fSseGhflaNh6zUw== X-CSE-MsgGUID: RHP+L3ImSGK5kkNMMPTLDA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="107277427" Received: from bergbenj-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.246.131]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 03:02:59 -0700 From: Jani Nikula To: Shuicheng Lin , intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Shuicheng Lin Subject: Re: [PATCH] drm/xe/display: Fix memory leak in parse_lfp_panel_dtd() In-Reply-To: <87plo86zua.fsf@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20241009232709.961628-1-shuicheng.lin@intel.com> <87plo86zua.fsf@intel.com> Date: Thu, 10 Oct 2024 13:02:55 +0300 Message-ID: <87msjc6zsg.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Thu, 10 Oct 2024, Jani Nikula wrote: > On Wed, 09 Oct 2024, Shuicheng Lin wrote: >> 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 >> " >> >> Signed-off-by: Shuicheng Lin >> --- >> 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 90fa73575feb..39ad71454d2b 100644 >> --- a/drivers/gpu/drm/i915/display/intel_dp.c >> +++ b/drivers/gpu/drm/i915/display/intel_dp.c >> @@ -6801,6 +6801,7 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, >> >> out_vdd_off: >> intel_pps_vdd_off_sync(intel_dp); >> + intel_panel_fini(intel_connector); > > It's a bit hard to follow, but this breaks the symmetry. If we end up > here, intel_panel_init() hasn't been called yet, so we shouldn't call > intel_panel_fini() either. > > What we want to undo here is what was done by > intel_bios_init_panel_early() and intel_bios_init_panel_late(). The > appropriate function for that is intel_bios_fini_panel(). PS. The subject prefix should be "drm/i915/dp". This is not about xe display per se. BR, Jani. > > BR, > Jani. > >> >> return false; >> } -- Jani Nikula, Intel