Message ID | 20231204102154.3309670-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 r17csp2666219vqy; Mon, 4 Dec 2023 02:22:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8uZsfMP1oQeWkoTlxMx8ylbS9UDaWwPQgxZTWhocwI5IxPddufPssC0CLmRjIWnpsagwO X-Received: by 2002:a05:6830:439e:b0:6d3:127b:6fba with SMTP id s30-20020a056830439e00b006d3127b6fbamr4577334otv.9.1701685349006; Mon, 04 Dec 2023 02:22:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701685348; cv=none; d=google.com; s=arc-20160816; b=wN8cV3t7vK57vM7+K3/no2Sa8VDYaIpsqDDKFXC2D2caXwe7byuFYUVxUAFdYbT5Ms GRosbElizGEDAtDipf+DVNzceX2YDU/nGu5GUMlA9fwzrCQ8HyPQnAq/AdugRQPuL+4O oNCA/llqkMBwB6yp8gxUKwDMHIrVDgPbWE/pYTpMFi3yIetXEv2gLl5NMvtjLdBUCbgH qtYy9rmWbwAmKo5/RcD3gqAbn5J8jtvrWPtItbF5XpfSnpqbjJKVK5YXdQ73kM3i64BW a9X2C/OPCcDO+2bqI4Xsm9xjfBjEA5EEVlfYoOHEZJx+bGbH5tdFvXDeP/cj5RbWYIon ZBSQ== 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=wQOu69tgnjEue1CEPNtdE/wKYlrfIqr6Jx1yYwe/AeA=; fh=Qr06Jl2SmKGxHywo38i+7SMfJrvy26lA47OMIQO+MBc=; b=ql8GQctI8tCobEwbd+saRQ20ZYlcK5C+GKRmDnTXwnqnqhyKjQZPDMnoQK1ad21Dzu loaWzMIdxwBWJO5Tuje7hq+dfXSle4VxOCMOoPKwNe4iPB2F/TW3aXHtZWcRfg0SQkfB vyTLwg8crEUxpljaIvRNe97Z4pZMqM5deeY7HQQxba4bxh375u3bFIBIAqGUYPhCbnNM iqyZFHcxb0KQLE2YZoWS9NHjkLo5bIoYiTqEmhwlNL7p2dBzm/lQoh2Qza//AVwvyHMe PZw4GgMjidd3taTEYp9xtr2VSuZK4Kg3Q8hSSl6KLHaStehw9jHWhjEONXcTWkSBOTCH WaHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id 191-20020a6300c8000000b005c65fe43747si3451884pga.279.2023.12.04.02.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 02:22:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 9BC18807C7D3; Mon, 4 Dec 2023 02:22:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343774AbjLDKWQ (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Mon, 4 Dec 2023 05:22:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235334AbjLDKWG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 4 Dec 2023 05:22:06 -0500 Received: from zg8tmja2lje4os4yms4ymjma.icoremail.net (zg8tmja2lje4os4yms4ymjma.icoremail.net [206.189.21.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DA315119 for <linux-kernel@vger.kernel.org>; Mon, 4 Dec 2023 02:22:09 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [125.120.155.9]) by mail-app4 (Coremail) with SMTP id cS_KCgBnbDRCqG1lCtdIAA--.53467S2; Mon, 04 Dec 2023 18:21:55 +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>, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] drm/radeon/trinity_dpm: fix a memleak in trinity_parse_power_table Date: Mon, 4 Dec 2023 18:21:54 +0800 Message-Id: <20231204102154.3309670-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_KCgBnbDRCqG1lCtdIAA--.53467S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KF1kur48WFyktF1DuF15Arb_yoW8Gr1kpr s5GF90krW5Ja42gFZrKF1IvrWrWa17GayUGFZ7uwnrG343G3WjkFZYk3yjvr90vrs29F15 tF47KrWxZFyj93DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkv14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK67AK6r4D MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV W8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAI cVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUd-B_UUUUU= X-CM-SenderInfo: qrsrjiarszq6lmxovvfxof0/ X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 04 Dec 2023 02:22:25 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784321429847946201 X-GMAIL-MSGID: 1784346416851990839 |
Series |
[v2] drm/radeon/trinity_dpm: fix a memleak in trinity_parse_power_table
|
|
Commit Message
Zhipeng Lu
Dec. 4, 2023, 10:21 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: d70229f70447 ("drm/radeon/kms: add dpm support for trinity asics")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
---
Changelog:
v2: Adding {} to correct the if statement.
---
drivers/gpu/drm/radeon/trinity_dpm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
Applied. Thanks! 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: d70229f70447 ("drm/radeon/kms: add dpm support for trinity asics") > Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn> > --- > > Changelog: > > v2: Adding {} to correct the if statement. > --- > drivers/gpu/drm/radeon/trinity_dpm.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c > index 08ea1c864cb2..ef1cc7bad20a 100644 > --- a/drivers/gpu/drm/radeon/trinity_dpm.c > +++ b/drivers/gpu/drm/radeon/trinity_dpm.c > @@ -1726,8 +1726,10 @@ static int trinity_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/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c index 08ea1c864cb2..ef1cc7bad20a 100644 --- a/drivers/gpu/drm/radeon/trinity_dpm.c +++ b/drivers/gpu/drm/radeon/trinity_dpm.c @@ -1726,8 +1726,10 @@ static int trinity_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);