Message ID | 20231204085756.3303900-1-alexious@zju.edu.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2631699vqy; Mon, 4 Dec 2023 00:58:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZ1r4pqLB5mvmuZaklqk3g+WdlyDqd6kCBfsdIo9Lr71Wl0ixPuVP1jwnTdx/HhuJ8rfyU X-Received: by 2002:a05:6a00:2383:b0:6ce:2732:1def with SMTP id f3-20020a056a00238300b006ce27321defmr2072590pfc.41.1701680307170; Mon, 04 Dec 2023 00:58:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701680307; cv=none; d=google.com; s=arc-20160816; b=X/iYDsjIgbTDjWPHnAi32sPtRCdTtxK2FCDJaq6pWeESJBP4QzqXNg8HrH6DTL9rdk lTLJPHWBRhHFiCMtEcKRl6CCzi+plkRvU+KP67HjxQ/mkMux0sTgf3MOvco/umWjfbTg i/OC6fkmfWxAGn8kVTvmu+AMqALUOlyujcC9C8JkwsFsg8J3mu+ChQsFMaAkPzmdPur5 W+JLci+2jevNznlmidzcEwPoDyPzKmhoztr7x5e19LMIh6LC4nAqv9eyZYj2/7nV6nkp ce569qO220Eid34eQ3ixFg0Uh5HhrBL2knar8U7AoJ48OAecBhyx+icsq/PdoxEiv35f rCWQ== 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 :message-id:date:subject:cc:to:from; bh=yLyQUJsUO588C55I3SWCTbX/XCGC91AIF6r80tEr5Qk=; fh=Kz+Lsu2F7zuHay5y4HO3Rfj4VI5Iz2Zh8O0i0Cay0Vg=; b=PyfE5QuBv+v5ztfQKbw1+GKihMLVdf3zmJJZ1LzckbAxvRDmvw+VpNEIWvHr0fbQAZ gKPZqmgmU2aQPTjGaRG3TjtldXDN5hi1flTSO7ltYoHIMv6BS6YlyblowBDQmq1W2dSr +JBNa2bd8CDX8lkXArTtcL5YYv2kYRW3qWu6MMNGKw6Z3OaiIcuKB4uyxvrWGpFape2m RGF53P4zdudZFHADRTSAdGXAzatortX+NSGrH3spJ94F7Cd4NPE3u4esoqHxX44SvXbH uD9GR3Z5P93umcAq3RWikQCVE8dIh+BbV8p0Yo4Nnd2K5snfMFfXFn5UXfWpsJwt+qgD RTmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s24-20020a634518000000b005bda050625fsi7438017pga.455.2023.12.04.00.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:58:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 25001809D3F9; Mon, 4 Dec 2023 00:58:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231925AbjLDI6R (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Mon, 4 Dec 2023 03:58:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231552AbjLDI6P (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 4 Dec 2023 03:58:15 -0500 X-Greylist: delayed 56456 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 04 Dec 2023 00:58:18 PST Received: from zg8tmja2lje4os4yms4ymjma.icoremail.net (zg8tmja2lje4os4yms4ymjma.icoremail.net [206.189.21.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DD6CD7 for <linux-kernel@vger.kernel.org>; Mon, 4 Dec 2023 00:58:17 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [125.120.155.9]) by mail-app4 (Coremail) with SMTP id cS_KCgCHjTWblG1l1INIAA--.54724S2; Mon, 04 Dec 2023 16:58:03 +0800 (CST) From: Zhipeng Lu <alexious@zju.edu.cn> To: alexious@zju.edu.cn Cc: Alex Deucher <alexander.deucher@amd.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, "Pan, Xinhui" <Xinhui.Pan@amd.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Jerome Glisse <jglisse@redhat.com>, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] drm/radeon/dpm: fix a memleak in sumo_parse_power_table Date: Mon, 4 Dec 2023 16:57:56 +0800 Message-Id: <20231204085756.3303900-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cS_KCgCHjTWblG1l1INIAA--.54724S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KF1kGFyfGryUtr1xXFWrZrb_yoW8Jw4rpa 1rGF909rW8Ja4jgr9FvF18tFWY9a1UG3yUGFZ7W3Wag3sxC3WjkF9ayrWjgryqvF4xur13 tF47Gr4xZF1j93DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvl14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26rxl 6s0DM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkIecxEwVAFwVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x0JUP-B_UUUUU= X-CM-SenderInfo: qrsrjiarszq6lmxovvfxof0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 00:58:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784282068184644493 X-GMAIL-MSGID: 1784341129442184588 |
Series |
[v2] drm/radeon/dpm: fix a memleak in sumo_parse_power_table
|
|
Commit Message
Zhipeng Lu
Dec. 4, 2023, 8:57 a.m. UTC
The rdev->pm.dpm.ps allocated by kcalloc should be freed in every
following error-handling path. However, in the error-handling of
rdev->pm.power_state[i].clock_info the rdev->pm.dpm.ps is not freed,
resulting in a memleak in this function.
Fixes: 80ea2c129c76 ("drm/radeon/kms: add dpm support for sumo asics (v2)")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
---
Changelog:
v2: Adding {} to make if statement correct.
---
drivers/gpu/drm/radeon/sumo_dpm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Mon, Dec 4, 2023 at 5:39 AM Zhipeng Lu <alexious@zju.edu.cn> wrote: > > The rdev->pm.dpm.ps allocated by kcalloc should be freed in every > following error-handling path. However, in the error-handling of > rdev->pm.power_state[i].clock_info the rdev->pm.dpm.ps is not freed, > resulting in a memleak in this function. > > Fixes: 80ea2c129c76 ("drm/radeon/kms: add dpm support for sumo asics (v2)") > Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn> Applied. Thanks! > --- > > Changelog: > > v2: Adding {} to make if statement correct. > --- > drivers/gpu/drm/radeon/sumo_dpm.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c > index f74f381af05f..d49c145db437 100644 > --- a/drivers/gpu/drm/radeon/sumo_dpm.c > +++ b/drivers/gpu/drm/radeon/sumo_dpm.c > @@ -1493,8 +1493,10 @@ static int sumo_parse_power_table(struct radeon_device *rdev) > non_clock_array_index = power_state->v2.nonClockInfoIndex; > non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) > &non_clock_info_array->nonClockInfo[non_clock_array_index]; > - if (!rdev->pm.power_state[i].clock_info) > + if (!rdev->pm.power_state[i].clock_info) { > + kfree(rdev->pm.dpm.ps); > return -EINVAL; > + } > ps = kzalloc(sizeof(struct sumo_ps), GFP_KERNEL); > if (ps == NULL) { > kfree(rdev->pm.dpm.ps); > -- > 2.34.1 >
diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c index f74f381af05f..d49c145db437 100644 --- a/drivers/gpu/drm/radeon/sumo_dpm.c +++ b/drivers/gpu/drm/radeon/sumo_dpm.c @@ -1493,8 +1493,10 @@ static int sumo_parse_power_table(struct radeon_device *rdev) non_clock_array_index = power_state->v2.nonClockInfoIndex; non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) &non_clock_info_array->nonClockInfo[non_clock_array_index]; - if (!rdev->pm.power_state[i].clock_info) + if (!rdev->pm.power_state[i].clock_info) { + kfree(rdev->pm.dpm.ps); return -EINVAL; + } ps = kzalloc(sizeof(struct sumo_ps), GFP_KERNEL); if (ps == NULL) { kfree(rdev->pm.dpm.ps);