Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1473978rwj; Sun, 18 Dec 2022 08:53:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7YobNMsmzoP6paxks0T4N3zOChd7A8iow9HlJwXboplIkUWcTs9TCgf/nqMwEPhksDqxRr X-Received: by 2002:a17:906:35ca:b0:7c0:b6ec:3ff3 with SMTP id p10-20020a17090635ca00b007c0b6ec3ff3mr30461711ejb.65.1671382433490; Sun, 18 Dec 2022 08:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671382433; cv=none; d=google.com; s=arc-20160816; b=P7jDkif7uHXusZZ/hc8qmjaAK4LvSgGR6jfOv0nC1LbRrltUD7VKE8W1oai9J6Yvzg 0ZvwatFj9rG//eRSHpFQD7Y48CldTDvtUqyv6Ko7MlGVTxJoseUHJK3tEHCafh320T3j KQs9Gc57KdBZ7pw0VsYqv8BzPqoDayBTODUXr8su4awdkMRXpj29VRsVZeNC4AtebYIb 2q1pEsbR/uqxFUjV1mQVhMqhaoUsSdMs9FhgGBh9LSTFS94jL7MkJdlc8PTTLqIumHLT NU0tTeLwUA4w5nGZC8qMWXGlCT+6qmFgKjzK2vkR6MxbMxbvjl7geX+aMTbnKWlXuHaw 4QoQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zK/3Bu3MQU3IWI8owSThHpw8MYpR+6bCfGNqKD2upNE=; b=la1wC6m0q3LKydCwtwJ1hBCf/AbUdnsfu88pVIfGslASRpDoeDylgKJMIEZubMocCK R5DmSRB6cvnPcXEWhEeE6tqW6pvpFwSqaawaB1M/2YBY7z/Ih+0odddRwDcRlWYRuQp0 gWMJHPdjrWINFctMTQhp4f7BKMTAAX85ny2079FFIa9HpMwAePi4Yq6kGxKgGt+GyJS9 vln3wU+PBnTLiSqAYZWTIVu6VPWFwDkSQ/zxkUKCQ8TGk5axkhOIie/KSjmhI5egHvMJ CJ+9OjkKlpocCgtbfCJDYthAUwD88wHsc16aXugHHCHbCvZ1/PC5Hc3ifFvZ1x9hJov4 cSyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i02OmITm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch5-20020a0564021bc500b004572618668asi6119623edb.461.2022.12.18.08.53.36; Sun, 18 Dec 2022 08:53:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i02OmITm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232316AbiLRQiG (ORCPT + 70 others); Sun, 18 Dec 2022 11:38:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbiLRQhN (ORCPT ); Sun, 18 Dec 2022 11:37:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70D9017A9D; Sun, 18 Dec 2022 08:13:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0CF11B80BE7; Sun, 18 Dec 2022 16:13:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A893C433F0; Sun, 18 Dec 2022 16:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671379998; bh=9cMVz/7RUy1bBNQ+ZXNVi7CT5W2f04dwS8UO0J5cu94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i02OmITmBri586SezchYlx5mE3yDYcGSNDaV8jTt2mBcAErqMxK2k8AnroNoAryV3 x9lBCyQDoi+hvfKTH+sHAEQGsaVNWP6d3YN5MnD/IZ5DK9n4TKDlIn2b1ixq4OWal+ ZRcIR4bTSrv94McXDRSXikuW8yFijVsf6ZFSrsdtW8tK4lscBb15ZAgarQRj0HX9vR 9ptnQR1DOZf/ZROx+0KTUbUDsDyy+WIUXc4NKE3SO3X1Flo/KVIwMmSScQqBOYKTwc Kkj3srrhsmfsz0osWfmh/LXMXs7rn3EIXtQpn4A0t5i3dOt4bifVQhjRL0Ycbyff9e 56nqwcOkXhAXQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: gehao , Rodrigo Siqueira , Alex Deucher , Sasha Levin , harry.wentland@amd.com, sunpeng.li@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, alex.hung@amd.com, aurabindo.pillai@amd.com, HaoPing.Liu@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.15 08/46] drm/amd/display: prevent memory leak Date: Sun, 18 Dec 2022 11:12:06 -0500 Message-Id: <20221218161244.930785-8-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221218161244.930785-1-sashal@kernel.org> References: <20221218161244.930785-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: gehao [ Upstream commit d232afb1f3417ae8194ccf19ad3a8360e70e104e ] In dce6(0,1,4)_create_resource_pool and dce80_create_resource_pool the allocated memory should be released if construct pool fails. Reviewed-by: Rodrigo Siqueira Signed-off-by: gehao Signed-off-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c | 3 +++ drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c b/drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c index dcfa0a3efa00..bf72d3f60d7f 100644 --- a/drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c @@ -1127,6 +1127,7 @@ struct resource_pool *dce60_create_resource_pool( if (dce60_construct(num_virtual_links, dc, pool)) return &pool->base; + kfree(pool); BREAK_TO_DEBUGGER(); return NULL; } @@ -1324,6 +1325,7 @@ struct resource_pool *dce61_create_resource_pool( if (dce61_construct(num_virtual_links, dc, pool)) return &pool->base; + kfree(pool); BREAK_TO_DEBUGGER(); return NULL; } @@ -1517,6 +1519,7 @@ struct resource_pool *dce64_create_resource_pool( if (dce64_construct(num_virtual_links, dc, pool)) return &pool->base; + kfree(pool); BREAK_TO_DEBUGGER(); return NULL; } diff --git a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c index 725d92e40cd3..52d1f9746e8c 100644 --- a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c @@ -1138,6 +1138,7 @@ struct resource_pool *dce80_create_resource_pool( if (dce80_construct(num_virtual_links, dc, pool)) return &pool->base; + kfree(pool); BREAK_TO_DEBUGGER(); return NULL; } @@ -1337,6 +1338,7 @@ struct resource_pool *dce81_create_resource_pool( if (dce81_construct(num_virtual_links, dc, pool)) return &pool->base; + kfree(pool); BREAK_TO_DEBUGGER(); return NULL; } -- 2.35.1