From nobody Sat Oct 18 02:27:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 476B6C43217 for ; Wed, 19 Oct 2022 12:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231989AbiJSMyd (ORCPT ); Wed, 19 Oct 2022 08:54:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233670AbiJSMyN (ORCPT ); Wed, 19 Oct 2022 08:54:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1E4AF9854; Wed, 19 Oct 2022 05:37:19 -0700 (PDT) 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 A4457B823CD; Wed, 19 Oct 2022 08:55:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD429C433C1; Wed, 19 Oct 2022 08:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169732; bh=qv9KGEdx0BBKOTuqWLd9oCsaYDbi4aharn99WByuFE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kf84WDqfvjt2ZtidE0P+ae1Be+ftOCyBPc6q3JX/KP3mODg89FBFtZ/GdeneyW798 yzWLMyGLxrI9aPeem6iylEutj/p2AnQoiXVNdxT8RsIOmVEG7fpO7+Z1QDWpIfcMuN IeEBlgruF27ZYYfnBZO0gqdeyQlrZkcn4bFjgi7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rafael Mendonca , Alex Deucher , Sasha Levin Subject: [PATCH 6.0 388/862] drm/amdgpu: Fix memory leak in hpd_rx_irq_create_workqueue() Date: Wed, 19 Oct 2022 10:27:55 +0200 Message-Id: <20221019083307.092290866@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Rafael Mendonca [ Upstream commit 7136f956c73c4ba50bfeb61653dfd6a9669ea915 ] If construction of the array of work queues to handle hpd_rx_irq offload work fails, we need to unwind. Destroy all the created workqueues and the allocated memory for the hpd_rx_irq_offload_work_queue struct array. Fixes: 8e794421bc98 ("drm/amd/display: Fork thread to offload work of hpd_r= x_irq") Signed-off-by: Rafael Mendonca Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gp= u/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 6e36427aab46..194142c581c8 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1296,13 +1296,21 @@ static struct hpd_rx_irq_offload_work_queue *hpd_rx= _irq_create_workqueue(struct =20 if (hpd_rx_offload_wq[i].wq =3D=3D NULL) { DRM_ERROR("create amdgpu_dm_hpd_rx_offload_wq fail!"); - return NULL; + goto out_err; } =20 spin_lock_init(&hpd_rx_offload_wq[i].offload_lock); } =20 return hpd_rx_offload_wq; + +out_err: + for (i =3D 0; i < max_caps; i++) { + if (hpd_rx_offload_wq[i].wq) + destroy_workqueue(hpd_rx_offload_wq[i].wq); + } + kfree(hpd_rx_offload_wq); + return NULL; } =20 struct amdgpu_stutter_quirk { --=20 2.35.1