Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2476125pxb; Mon, 18 Jan 2021 20:29:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJeZ/rIsmXQM6wvIWAGh/bISSpnrBjhjNfp68XMfTA4pdTGyN23nhzEPdWNRMNif+X3T9L X-Received: by 2002:a05:6402:1d86:: with SMTP id dk6mr2019638edb.126.1611030597188; Mon, 18 Jan 2021 20:29:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611030597; cv=none; d=google.com; s=arc-20160816; b=b+7VTwGXfntttKAhi5DU2cUF3WBoVDM9xwZqd6iZ0FRXUBaEe5jeKe2a7CBemfc7jC afxHWc0qKzjbtcYrTh2iGc0F80ZrUpgFtMqnLdILjNWaR/eRNoHswrMfR/HOrPL6QLow m6YftKEn2sK3v31a+vJzkF08oQZnpuFy1efZyTteEy8fLrMsum2NmyMYK/+Gh9D5vLfb 5TG9Q6JkCeFhoxNmWZfF+5qoaODrIoEM53SQR12gOKWLpuzp/C1BJ4//DfqvkJdTWTcx mTv0ANOaRh29D/8NDqzn5kbIt9itXhSVlMhAu+gTUW5yFtumh6yov63fw00ca/cu7wUe 0LNA== 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=K9l+hgDjf37Ggg0Z0p5SUPLTCmST4sYadsOrGZE53VE=; b=drok/MnIsdKFDHXEA09pn/sgF6if3ykPMdOZIRuw0RCIwxA3I6ssurwHJ7qo/YIxfc k64kcJ5FT03F96WOhPoci3f923ubkq4RXvuWUyy91IsgGoWgzF2KWWVqFZ13RJYwGkS1 bDY6WNmSQybFnGP679bxxY67vH2MWUlBAlq3Lw6L115jxRzbwLNLzkZnQS+Rlh4kU1Oh 95hn5lPlOO5hwwKI9cy1uAutFoCcOQ/Q/RgpVhHu61OF+psUs1CEnTeeXM/5j1k3aW4K 5zOWFa4TxiEgfnduqRMN6StblJgowX3RT6avrCuMNcf6XcqERStlI65Xdy9nLL+S2OIM St+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XKTuot6k; 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 x9si4541785eje.250.2021.01.18.20.29.34; Mon, 18 Jan 2021 20:29:57 -0800 (PST) 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=XKTuot6k; 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 S2404922AbhARO0c (ORCPT + 99 others); Mon, 18 Jan 2021 09:26:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:39830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390235AbhARLos (ORCPT ); Mon, 18 Jan 2021 06:44:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B14522D6E; Mon, 18 Jan 2021 11:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610970229; bh=IO07lAPmVIHL6U9iLfamBIZXzOpk67bl0Wv3eCpJyL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XKTuot6k/sEHFBrsWq0/lY6iVCIi4n1ZTdAGheoJXZMhb9bWhQeQ18K4m67gagHqR B5uonpUGxFXFGKN3OHCV4Et8Nizq59lhQWmb52whaE8K249QyxSS+0sNo5u7m0U0jk eDoZgnvu4r634tPbLLop6CIcnpSbKK0ZZPnvdRJE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Deucher , Jiawei Gu , Sasha Levin Subject: [PATCH 5.10 091/152] drm/amdgpu: fix potential memory leak during navi12 deinitialization Date: Mon, 18 Jan 2021 12:34:26 +0100 Message-Id: <20210118113357.116223923@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210118113352.764293297@linuxfoundation.org> References: <20210118113352.764293297@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: Jiawei Gu [ Upstream commit e6d5c64efaa34aae3815a9afeb1314a976142e83 ] Navi12 HDCP & DTM deinitialization needs continue to free bo if already created though initialized flag is not set. Reviewed-by: Alex Deucher Signed-off-by: Jiawei Gu Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index a6dbe4b83533f..2f47f81a74a57 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -1283,8 +1283,12 @@ static int psp_hdcp_terminate(struct psp_context *psp) if (amdgpu_sriov_vf(psp->adev)) return 0; - if (!psp->hdcp_context.hdcp_initialized) - return 0; + if (!psp->hdcp_context.hdcp_initialized) { + if (psp->hdcp_context.hdcp_shared_buf) + goto out; + else + return 0; + } ret = psp_hdcp_unload(psp); if (ret) @@ -1292,6 +1296,7 @@ static int psp_hdcp_terminate(struct psp_context *psp) psp->hdcp_context.hdcp_initialized = false; +out: /* free hdcp shared memory */ amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo, &psp->hdcp_context.hdcp_shared_mc_addr, @@ -1430,8 +1435,12 @@ static int psp_dtm_terminate(struct psp_context *psp) if (amdgpu_sriov_vf(psp->adev)) return 0; - if (!psp->dtm_context.dtm_initialized) - return 0; + if (!psp->dtm_context.dtm_initialized) { + if (psp->dtm_context.dtm_shared_buf) + goto out; + else + return 0; + } ret = psp_dtm_unload(psp); if (ret) @@ -1439,6 +1448,7 @@ static int psp_dtm_terminate(struct psp_context *psp) psp->dtm_context.dtm_initialized = false; +out: /* free hdcp shared memory */ amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo, &psp->dtm_context.dtm_shared_mc_addr, -- 2.27.0