Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp650782rdb; Fri, 26 Jan 2024 06:52:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwY1l+BAr3mi/FhtBJVh0A69bD7xMIXqm/bEEjKts9vSnE5NTb1VqPkcsFaGre5rdUFO+F X-Received: by 2002:adf:ee8a:0:b0:339:2bbe:eed5 with SMTP id b10-20020adfee8a000000b003392bbeeed5mr500497wro.230.1706280779240; Fri, 26 Jan 2024 06:52:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706280779; cv=pass; d=google.com; s=arc-20160816; b=x3QnKC1Urelr0J6d0TYtrD6AuxRIS7H4OxUM3wyKF+hrAq5iDntjEAjyS2+HppZF96 n1vVPpGyujSUDPHWIhcFmZjKmKoDsb9ZtzJjXMN4WX3MtsUT5MXwdM7e7+OMtBmJysji ly4LiQ25vRbYhfw3lAKBoeWEeO7NA4DfIps/fZoME1jdO3OeZb7gDmWu/2XgSJZG+bcI 9uoWGcu4r1e306gTqdBNYhE5OcAtjxZfiG0YG7T1y27q1EmTigYQIxP1ytNsZ3mOVcGR Y1pEZzPMpUypmGORVm0G3nfUEPdvRx0k/Kj9NN6Wge3LgIcosxjV4NMbCNHG6/MVrlie LZFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1zREwcVlA7rIvrCy3Mca+184eFTk8h5GV39nc7UpEOw=; fh=TRwaA9hTVevojQCOz8AUtB5CW3U4mzmDxLLNHPL7qSQ=; b=SBtdijpNOgu8PN9qah2FnNJFE/5EBNXcy5dLPMtLCTjDUY7tg0utltOAM2mX8QNslq SpTsIEEjU18KL5+Tblv5tRGY7ofQFEUYQze7wx3L9l5xbYpcIuRCYWLyzRFZ/iuOY0ht UQVmNtId2kvOdLs7GDbH0whKKpqaY8zwVEpAtA3L90U9S4PmqBPd20232rswpNxd1JYf UE/9KwosOQMBHNuAuANnwsya5u16qIvi10eU9ypC++7qx/WzZT11ShmChg9zjtuTUY5X jNmU11IR2oWotpUIJu/mjEw+CMXuMpe88nsBN4Vfsdc9l05WtiIwoA91vMgkIFho5pIZ kLPQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nMMN5vKw; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u17-20020a1709064ad100b00a351a617b34si124480ejt.918.2024.01.26.06.52.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:52:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nMMN5vKw; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 492421F27DAC for ; Fri, 26 Jan 2024 14:34:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 405641CD26; Fri, 26 Jan 2024 14:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nMMN5vKw" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 352601CD1B for ; Fri, 26 Jan 2024 14:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706279686; cv=none; b=pa2cvpTvhaJitxxn2Lx+2e8tT5ZbTCAyW4v0PBD6XHORfMZLwy29uPlncVkH448+37QgvGMxZ+DAXDn0HZpJ6PXO+EQGuxi0Yl7xRbfH+vsOV4Mz2/kbObp1gp+Oy5k64GkomBQucuouULvbCzRivithSJfhMnUM9ZZ5NXgogEk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706279686; c=relaxed/simple; bh=m9PT2Y6MD4xV1VmnnGIAd5vfJa/7eZ8Onp2JUOf3Gts=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OEXTvDxlo5dX3a4UjWgbBYBJ07zAVviMx5EGZb8Y2ZtWdiOXUBln3KLQjYHy7OkvZBrWf+KSBlMsOO6m7OGsQ31Te8luP+r7cxsPqWgp8sO6vnFI4CJPkkF55CSI9dZ6bgd7Xb1XvepSl/FhFAYodkf7kxJbu4kCgTyJzpB4Q3Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nMMN5vKw; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706279684; x=1737815684; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m9PT2Y6MD4xV1VmnnGIAd5vfJa/7eZ8Onp2JUOf3Gts=; b=nMMN5vKwJHEEJqI9JbO9z35IYk6CdfvlhU/02rTn3fZwP7Muba6v9BAS Wji+iFlPqIDMlQRnf5lwqPD+Ka4rQJLITL8Ferhb2tmcwry/KYYazz4wL gONCfgTs9zKoOcWRGVJf23MnsihXIQNDSjlhN+pJvYb+hxs81o4x2DXG3 bP9y1POAfykt6ZpZY5qoif8PuwKb5IYXHbd7OHBulLLtwUSS6+Z6oApHc JE8S8ygq1fFCCC2NvV7TOTUYczj/PL/e3ZgLUJ+oTfvL9tEFQl4dCxxfK kyqgAOllUuluuDhfahMfgjBTurA2agW+9USIlZo3Wx4E0ziLYO4yzBcos Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="9139832" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="9139832" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 06:34:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="906320961" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="906320961" Received: from tgl-lenovo-03.sh.intel.com ([10.239.87.93]) by fmsmga002.fm.intel.com with ESMTP; 26 Jan 2024 06:34:36 -0800 From: wangxiaoming321 To: lucas.demarchi@intel.com, ogabbay@kernel.org, thomas.hellstrom@linux.intel.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: wangxiaoming321 Subject: [PATCH] drm/xe/display: Fix memleak in display initialization Date: Fri, 26 Jan 2024 22:34:33 +0800 Message-Id: <20240126143433.997078-1-xiaoming.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240125063633.989944-1-xiaoming.wang@intel.com> References: <20240125063633.989944-1-xiaoming.wang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit intel_power_domains_init has been called twice in xe_device_probe: xe_device_probe -> xe_display_init_nommio -> intel_power_domains_init(xe) xe_device_probe -> xe_display_init_noirq -> intel_display_driver_probe_noirq -> intel_power_domains_init(i915) It needs add a flag to avoid power_domains->power_wells double malloc. unreferenced object 0xffff88811150ee00 (size 512): comm "systemd-udevd", pid 506, jiffies 4294674198 (age 3605.560s) hex dump (first 32 bytes): 10 b4 9d a0 ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 ................ backtrace: [] __kmem_cache_alloc_node+0x1c1/0x2b0 [] __kmalloc+0x52/0x150 [] __set_power_wells+0xc3/0x360 [xe] [] xe_display_init_nommio+0x4c/0x70 [xe] [] xe_device_probe+0x3c/0x5a0 [xe] [] xe_pci_probe+0x33f/0x5a0 [xe] [] local_pci_probe+0x47/0xa0 [] pci_device_probe+0xc3/0x1f0 [] really_probe+0x1a2/0x410 [] __driver_probe_device+0x78/0x160 [] driver_probe_device+0x1e/0x90 [] __driver_attach+0xda/0x1d0 [] bus_for_each_dev+0x7c/0xd0 [] bus_add_driver+0x119/0x220 [] driver_register+0x60/0x120 [] 0xffffffffa05e50a0 Signed-off-by: wangxiaoming321 --- drivers/gpu/drm/i915/display/intel_display_power.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_display_power.c b/drivers/gpu/drm/i915/display/intel_display_power.c index bf9685acf75a..3b48a1cb7c54 100644 --- a/drivers/gpu/drm/i915/display/intel_display_power.c +++ b/drivers/gpu/drm/i915/display/intel_display_power.c @@ -36,6 +36,8 @@ for_each_power_well_reverse(__dev_priv, __power_well) \ for_each_if(test_bit((__domain), (__power_well)->domains.bits)) +static int intel_power_domains_init_flag = 0; + const char * intel_display_power_domain_str(enum intel_display_power_domain domain) { @@ -1016,6 +1018,11 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv) { struct i915_power_domains *power_domains = &dev_priv->display.power.domains; + if(intel_power_domains_init_flag == 1) + return 0; + + intel_power_domains_init_flag++; + dev_priv->display.params.disable_power_well = sanitize_disable_power_well_option(dev_priv, dev_priv->display.params.disable_power_well); @@ -1041,6 +1048,7 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv) */ void intel_power_domains_cleanup(struct drm_i915_private *dev_priv) { + intel_power_domains_init_flag = 0; intel_display_power_map_cleanup(&dev_priv->display.power.domains); } -- 2.25.1