Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1056603pxk; Mon, 31 Aug 2020 08:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNBpWiRjMP3ShDliIub76nnzJJPA06Y0BrbUbBUwOUadwAqowh7vtaVR+xbs+XdtldDOiL X-Received: by 2002:a17:906:393:: with SMTP id b19mr1640746eja.268.1598888327308; Mon, 31 Aug 2020 08:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598888327; cv=none; d=google.com; s=arc-20160816; b=RQ2TefHQGdvbHTi5kF7M+3OaVtCD/y95mTLEfMpVNBZVddNYufzKz2OJG0RUFl9tLl /aRczajNCqK6bFYWtdxiVEk8A0mQJtyEHcKu4XMTF06iMyyOdTby6eFLwtp/2YXTOLvU 2uNTGRKYFEn/tPkHM7BXa8CbbG8qQD0HdiiB2pafUsPRqkVAq4q2l3IeeDs5m9FD8c9i lt1WB9PqppfN1xQwasmzPOdXuGcbymot/KpbTcI51zq6l7tS/38wRlStfffTosjHXA5A RKeC2PC/+poQvCswPiCDB8iKtvDmkK0OdrfLOvWJxwaxtGxzRLum/reGR3KzUASyHd7I D81g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8lw4WTIuon2oY3E7J5TfEZdUFTy2AUjkz/EXB/fDR2s=; b=PVgfxJoPBSureRC+0hpL6o4FhX515ge9GB5SAcMsuPlKDjeEMtQn7p3RG/W9owc4Vk HDXlTaR+VAR1AgwDsUVtyuU1AZDe2IVopdgnR6BMUOAdAP+oEpkLtkwQ0nviXY8uQVvM LN3NUQMqKIMV3qGXSWyN2KfFquQwHRHpm3KrVc7L8mrYWGbqhRuztOp9uQOlDiq8T0fo UJz7WJxY8boVwxbdgax0w/U/kzhdHBWn17pgmfhsK7XSP7g8kXQNptU6rC0dyQfpegkR RuStaI1K8HWG3SEDsmtSyqEkD8X/WeqKM3/U4AobGkG/B1cGa9YQF8WET2AIRMaiMmCv 1h9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HphBn4hE; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv22si1099699ejb.536.2020.08.31.08.38.24; Mon, 31 Aug 2020 08:38: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=@kernel.org header.s=default header.b=HphBn4hE; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729308AbgHaPgt (ORCPT + 99 others); Mon, 31 Aug 2020 11:36:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:40244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728676AbgHaPaf (ORCPT ); Mon, 31 Aug 2020 11:30:35 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 030DB206F0; Mon, 31 Aug 2020 15:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598887834; bh=r5cRSKBQIhNHoIQhIfZua12ERWVZevFIYQnYN1GlsEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HphBn4hErUKQFq02FjwnJjW2Eg0WOJ3NhHcZS3EVKv/brHqAuKWo46FPtArk1BXmI pXVWpxqnokQfeD6SkVL7VDdDPDNnvDpWhxwEaIOHJdRTBOiy+k/fTtZJH8fFyD2qvg IAru+w4Bk5l5IDqbnVY5YIoAmNEskl72B9cIRdUU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dinghao Liu , Alex Deucher , Sasha Levin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.8 40/42] drm/amd/display: Fix memleak in amdgpu_dm_mode_config_init Date: Mon, 31 Aug 2020 11:29:32 -0400 Message-Id: <20200831152934.1023912-40-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831152934.1023912-1-sashal@kernel.org> References: <20200831152934.1023912-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit b67a468a4ccef593cd8df6a02ba3d167b77f0c81 ] When amdgpu_display_modeset_create_props() fails, state and state->context should be freed to prevent memleak. It's the same when amdgpu_dm_audio_init() fails. Signed-off-by: Dinghao Liu Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++-- 1 file changed, 8 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 0682fd363cb50..580c17c95a1d8 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -2822,12 +2822,18 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev) &dm_atomic_state_funcs); r = amdgpu_display_modeset_create_props(adev); - if (r) + if (r) { + dc_release_state(state->context); + kfree(state); return r; + } r = amdgpu_dm_audio_init(adev); - if (r) + if (r) { + dc_release_state(state->context); + kfree(state); return r; + } return 0; } -- 2.25.1