Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp880585pxj; Wed, 16 Jun 2021 16:09:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC8W+BiXshlPzVuRPP8mhqmtgNYLoE1RmGMkwc6X9zkdig4EmiHXMOw6SImXDj7l+R3jNQ X-Received: by 2002:a92:dd07:: with SMTP id n7mr1361019ilm.269.1623884987334; Wed, 16 Jun 2021 16:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623884987; cv=none; d=google.com; s=arc-20160816; b=aNczSkl+IKBb4lnop28uaqlF1O24soR+DehTfa+3AIFsH11GOJK0CdmqmVulMRFBOr 5/P0dcPwF3z2V66BJOWkb5g2V8LmNDucsXMASskRdr6RM4CiFOgSVnywPm+RaRzeY9o4 tXmCAGn+fWf6zwbEbWCbNUCNJapmKqDBrRJun97K7APRVIOQXzsSMv6eJBPt7ZKoob6z 8X6Jcc2Ygn6Zypoe792zi2OaGhfTyrolJdjJEh97yqflHBcx6POVb+LDU8Cp1tYjqBsq ToBQQtMrKWBtw8Dr+B5i3X45gHUhP+YbeBJFpTwtdCgaadcaPUXFVN3tpQKKr23SuCgc aq2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HBGBW6UJxlcZQlpNuOjX7ZqVnQEzLCXDpdQPnMPMUKM=; b=vG40lPOW12Uk5Nyh+efmc0tLfpZ6l5/Q0yUn3OzaP0z6zCPzJLuCN6elhkSMxsiMqo d4yb7/CoTvSauXf0E8+kKRwfajPKNrAsKYwvl3Z/FDibuGPqHL3cn+jlKLsMdefo36fV TqPlzb5DckHcjNJNxFkK6Jjt0OpG2JJ5m2yBggIZAzmwKi+n260tOFF68ac8uzynENZO QpF52Jy6wzMIuEuWbjv9BXyARcVp1iu7ktv5bBgaxdo898a+kGnRt83dDoulxArU6fgU i/gkhNWVd2G4alG3wLyZ3tz+qnf1JZu2w72ZVopukhRlctJ0iafUlODnxA1i6IpceaYO viwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n48jbb9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u16si4559051jat.121.2021.06.16.16.09.35; Wed, 16 Jun 2021 16:09:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n48jbb9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235810AbhFPPoJ (ORCPT + 99 others); Wed, 16 Jun 2021 11:44:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:51360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235471AbhFPPmA (ORCPT ); Wed, 16 Jun 2021 11:42:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F40EB613D3; Wed, 16 Jun 2021 15:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623857872; bh=RU63UG+hsOXLvJl/eg0xfbdqV+vXBYCf368CdSAr4J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n48jbb9Twm7QgGJfST4klz0yOu2Md/UacSZ8fd4Z16tth+zGcFsQFvy64wulMJkDq e0c2719MrIjSJrTKTjqdPcpzAJ47/oKPDP+FYw4Axtt2Dy26S9welaFP87UgKqQg84 rgsEonVQcKLPklpOwLRoInwBqRqMKaeJs+5dVcPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lang Yu , Roman Li , Nicholas Kazlauskas , Qingqing Zhuo , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.12 43/48] drm/amd/display: Fix potential memory leak in DMUB hw_init Date: Wed, 16 Jun 2021 17:33:53 +0200 Message-Id: <20210616152838.001993540@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210616152836.655643420@linuxfoundation.org> References: <20210616152836.655643420@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Li [ Upstream commit c5699e2d863f58221044efdc3fa712dd32d55cde ] [Why] On resume we perform DMUB hw_init which allocates memory: dm_resume->dm_dmub_hw_init->dc_dmub_srv_create->kzalloc That results in memory leak in suspend/resume scenarios. [How] Allocate memory for the DC wrapper to DMUB only if it was not allocated before. No need to reallocate it on suspend/resume. Signed-off-by: Lang Yu Signed-off-by: Roman Li Reviewed-by: Nicholas Kazlauskas Acked-by: Qingqing Zhuo Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 69023b4b0a8b..95d5bc2da178 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -871,7 +871,8 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev) abm->dmcu_is_running = dmcu->funcs->is_dmcu_initialized(dmcu); } - adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv); + if (!adev->dm.dc->ctx->dmub_srv) + adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv); if (!adev->dm.dc->ctx->dmub_srv) { DRM_ERROR("Couldn't allocate DC DMUB server!\n"); return -ENOMEM; @@ -1863,7 +1864,6 @@ static int dm_suspend(void *handle) amdgpu_dm_irq_suspend(adev); - dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3); return 0; -- 2.30.2