Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2608380rdb; Mon, 4 Dec 2023 02:22:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJwcYGM1/IxEsYzL/6K27KPq0NW0+Qx8L8xAEX3TAqUrLunm/sqyDjlvfDaFp+YaqJJXhV X-Received: by 2002:a17:90a:6c22:b0:285:8a2a:1744 with SMTP id x31-20020a17090a6c2200b002858a2a1744mr1228765pjj.0.1701685353958; Mon, 04 Dec 2023 02:22:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701685353; cv=none; d=google.com; s=arc-20160816; b=K7uuSrT3w8NXxTXk0akCEOiyUGlPtOhAGnVXtZmuxI8TfXPAFZr/jmBlZwVdXKY4wU MfGSzfC07tvgaTBiGVyz1a4OjMjNie3GH5bmYFpALA2QxZ0GkK+BSYkhmwswjfSCCKzu OuFwPbLeDrevJ3R4NHdP43/S67FqMorOK7dQTYZAQqfGv8ggwcXEO3R9qGAMQQ86Rb6G yzVqj2zfGTRheQ3WXlKvKBoj+3gbE+FHG1HWsDtmkQeN77QO+IkVXZ1S8jSw9hbY70fA zidRVaSwr2qvqc+CjHDdAGyd5Wp6XCZ+bWp/tBuZmsLw8OQoV8Ca3eEkqbCegIeQ9hD7 LKUQ== 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 Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n9-20020a1709026a8900b001cfa17ec30dsi7333439plk.508.2023.12.04.02.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 02:22:33 -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 1E8AC8089E5D; Mon, 4 Dec 2023 02:22:30 -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 + 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 ); 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 ; 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 To: alexious@zju.edu.cn Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , 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=unavailable 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: 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:30 -0800 (PST) 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 --- 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