From patchwork Wed Oct 19 08:27:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp314031wrs; Wed, 19 Oct 2022 06:03:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hE4TnUUp9iP7qbNlIaTCgtpFym7R7pEjui2b71vRCMUHwrcHlPz1UpPfBviMaJTnOIcs7 X-Received: by 2002:a17:902:ea03:b0:180:b53f:6da with SMTP id s3-20020a170902ea0300b00180b53f06damr8174969plg.69.1666184635643; Wed, 19 Oct 2022 06:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666184635; cv=none; d=google.com; s=arc-20160816; b=DPeZqJWR3TjmyFSf9pQlP4hKuS2ie2kZ4eHT1sVJCtXi0UPzmsi2PZu5TxgH/7N0N2 KAp/Urk4B7vdOqC5D0m2RT/X3QEzF++UTcB2Xl/qrtlgBtl0gWXO1pIUPpbqLmMh/YXf HQ1q8YMgYi+7dT7Wmry9DqCL5kdh/3+PD52eZ56K300oICJb+m8wO29bed09APP5iQD2 nkE94zv5pXzcwa6PuwuvEvzMenxe5VjAtkH99jnqIKDLviECtTPuusG3J1CZ6x2/bBWP aWl03kJncT+WSomrJvutq72A6jMMmyRsxUL0YhpT4fY+DHjHv5z+0SJYY8TX2cxcsbdA 53Jw== 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=1YonGDuxTykbpBZw6O+8s4iU2LYS4Uoi+w2jdXPEw38=; b=NN84Bg6OT/u3+m1ciCK+i5cjUAJz58soesjsx2cg/wYMqYCFIn2dQ5zN1Na9dLUx8X PNF9dhuWO8VYHQ9ZoEZSXLFQQos99CaiyuWWYmpTB0jC5SvyxMDX8A4rJopZndQC+mJx C+BD94gHHsH7QU4d4QHDjb/AZ6n8GDudTA/I2urYL7NyDenuNb+ZsUSXNrUVSdbaqSG3 a87JDqNI52RvRTuQ2U+o7nzufqwzgVhg9VlhsAiBd2ioqO+tgeaO2t0n0l6QlIB5SXtT m+pvi9whqUcy8E25jmEuvgpaaK9jLxeDwDoeoSN1B73Es1Wm0+pN5riW6a/bhoSO1k9b mkEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Kf84WDqf; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a170902d48800b00177e5c1d5d0si19175612plg.347.2022.10.19.06.03.21; Wed, 19 Oct 2022 06:03:55 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Kf84WDqf; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229956AbiJSMyc (ORCPT + 99 others); Wed, 19 Oct 2022 08:54:32 -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 X-Spam-Status: No, score=-7.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747121220355136352?= X-GMAIL-MSGID: =?utf-8?q?1747121220355136352?= 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_rx_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/gpu/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 if (hpd_rx_offload_wq[i].wq == NULL) { DRM_ERROR("create amdgpu_dm_hpd_rx_offload_wq fail!"); - return NULL; + goto out_err; } spin_lock_init(&hpd_rx_offload_wq[i].offload_lock); } return hpd_rx_offload_wq; + +out_err: + for (i = 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; } struct amdgpu_stutter_quirk {