From patchwork Sat Oct 22 07:23:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1097240wrr; Sat, 22 Oct 2022 01:07:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Ec630TaPWSHcVxm9866w4AtSziA+fXn6+YOYhoEEF+/rSNifumgDRQT0VHTsB/s3fVoX/ X-Received: by 2002:a05:6a00:88f:b0:530:dec:81fd with SMTP id q15-20020a056a00088f00b005300dec81fdmr23568412pfj.64.1666426019687; Sat, 22 Oct 2022 01:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666426019; cv=none; d=google.com; s=arc-20160816; b=x7rdQxRpxhvpq0o5SM9WuJEv1aOgibzPKC0g4TmlyMHIFECpD6wluc6LkDUBYwq8PW OST0KGp/huvPJSCNoXWnyxKWjgSFqD6yzere2y7fom2AE19rtb7VvFRu8eBNt9BVfNwR 6AGLcmwJyeBcCAffde63nLV1imP6hsXgfK5Jum/cDlJH4TkcCLBYtIcv0d//HVTGmXzs S8SPYShu4PtxpZOd7V0qwnTmS4jNkELKThvDNEoeCQSBLhr04L3yY/nwO1OxV7JjhpRJ m0mcUNhgsxHYuofGEEtm6/CftxIcnJ0+rrpAaDcqroe+hELZ1bruvagaYBZCZIicF1ov grOg== 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=izM7hl+4kSZE1BGEwOqban3+G7ebJ85ZO56F1crhC24=; b=PGQlUrJVwSnPkIIIJXXtXtKJroDbBdptFP8efLbugTGAJkfIG1jBwrRjIKJX/zTWmw eEymyToZvduDCkdTXo7hGVQTbHYJxsxeN5i4XoOYXd7jzrbI8Azm2iime0SNLS7WUjfT YyOw/1dXuF6QoBQcquhsNaTB11FE84B42Tf6iub+QnT/nrAPiSyEDIOeXQ6g1JaJpZV/ xhgrazd0T1kANpjlkBdGZ3qDu2x3BwdjTUsVOqxZeiPMjl5C/nwpGL70m1Rjab8S80wT GTwMR0en/ixZ7ECbC9pF4OIqMpvEco1MA0zF5Y05ZAyUCLKF6ParTUNCNnr2tCN5AYFD 2p+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q74jiVVv; 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 pc1-20020a17090b3b8100b00212221d926bsi2706501pjb.150.2022.10.22.01.06.47; Sat, 22 Oct 2022 01:06:59 -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=q74jiVVv; 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 S232466AbiJVIG1 (ORCPT + 99 others); Sat, 22 Oct 2022 04:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232821AbiJVIAB (ORCPT ); Sat, 22 Oct 2022 04:00:01 -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 42DE81A9118; Sat, 22 Oct 2022 00:50:15 -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 F37C6B82E22; Sat, 22 Oct 2022 07:49:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61929C433D7; Sat, 22 Oct 2022 07:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424998; bh=bHH5Vz9WUGOiTeAeeQ+WA7OaZoShJlUuxzwNps9q4Fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q74jiVVvn+zf0WRBc1MO2gU2O19xu9G151oug8af/6jlh54eYbi4LrL5KQhz5U9KT rBg0LHfyQvuhqVRbV7HltIzeoop9RT21WpEQuhkEVZv5ImoGhcCLr64b0luNpYj0n2 EAVrgtVLf0+TmehszVjur9lI2cS1xPRIVeyzMAJ8= 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 5.19 327/717] drm/amdgpu: Fix memory leak in hpd_rx_irq_create_workqueue() Date: Sat, 22 Oct 2022 09:23:26 +0200 Message-Id: <20221022072509.187763601@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747374330118436373?= X-GMAIL-MSGID: =?utf-8?q?1747374330118436373?= 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 d752aadd34bf..612970a9fe65 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1363,13 +1363,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 {