From patchwork Sun Dec 3 17:16:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhipeng Lu X-Patchwork-Id: 172967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2332789vqy; Sun, 3 Dec 2023 09:19:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiGgk+BccZZhGHHp2pNbeJ0u4l2p9DqTpFBSBF9GLhG5BgKgIQ+WVePWHELv+zSsXJIx0q X-Received: by 2002:a17:90b:35c1:b0:286:6cc0:b90c with SMTP id nb1-20020a17090b35c100b002866cc0b90cmr552475pjb.67.1701623981748; Sun, 03 Dec 2023 09:19:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701623981; cv=none; d=google.com; s=arc-20160816; b=ScLBLHsBLLcJ7O8wwsEaywKj/UfztzepJaVluW2PoHAL7O+2s6lfi4PL2/UHXmGmAL XWs8bsx76N0zUrlH1LwpSvLomPvNQY86pMKx7bno39evkjf4X/6hBS9GBrPCAvjb2HkV jji/nm/JY54y9lmQd3wX5jqC0gr6MCPPxbtVVmcF8/4IyMbZgdthM9VNSRevJcFhlj9V FAnnfWuCON9UqNtX3PbMf5p8p+2mqRdmk8eMyz5Kvlx6qdhKMryLbyeY1x4uSsoxW9X7 4Q8Ic9onU5rUM3a22Bah08BwsczqgyTh0zmhf06nH1EYoRRIIgzoeeAs95se1KEIMyfn L3Eg== 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=GCANMKs2AblxedaZwIxNfcIgnQ0Sj1rw52vmWNTcSDM=; fh=Kz+Lsu2F7zuHay5y4HO3Rfj4VI5Iz2Zh8O0i0Cay0Vg=; b=ZN1inBj/iYKmoFEPmmMYtRWwuqOt26wGq4Ykzr0EYecOQvIQ0S8osWV84azVtZC2DZ pNRwU81dWSMZTKu90Be/XEVLmnCfbSxevAzPIne6KdzhD80k71guXl+JwftvNbF3v46t mH10ZPrBJB55dxODxxAjINqxYwcPJaSms1QNNILy6l3loo/St3eVqaABW9vb1GmKqm3z 8poFNwdvkQotN1mdQyG7BZjbb+mONMCPziC2qylMcbEGWzdtZUV+uxWC/ffbUwEcIv0H gAqGusLlo+bABrsEAamBHWfzW65XYVQ4s2GxNncVMpftxUGceegNpxCjPyHhfNGjhf2E IoVw== 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:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id px17-20020a17090b271100b002774d978e19si6588759pjb.175.2023.12.03.09.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 09:19:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 804C38086535; Sun, 3 Dec 2023 09:19:39 -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 S229739AbjLCRTZ (ORCPT + 99 others); Sun, 3 Dec 2023 12:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCRTY (ORCPT ); Sun, 3 Dec 2023 12:19:24 -0500 Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net (zg8tmtyylji0my4xnjqumte4.icoremail.net [162.243.164.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E95C6C8 for ; Sun, 3 Dec 2023 09:19:25 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [60.177.97.75]) by mail-app2 (Coremail) with SMTP id by_KCgDX3tYNuGxlzhdCAA--.53204S2; Mon, 04 Dec 2023 01:17:01 +0800 (CST) From: Zhipeng Lu To: alexious@zju.edu.cn Cc: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Jerome Glisse , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/radeon/dpm: fix a memleak in sumo_parse_power_table Date: Mon, 4 Dec 2023 01:16:43 +0800 Message-Id: <20231203171643.3287229-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: by_KCgDX3tYNuGxlzhdCAA--.53204S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Xr43Xw47WrWUuryDWry5CFg_yoWkJrXEkr W8Z3s3Wr4jqrn5X3W5Ar45urZakr109w1ruan5tF9Yqa4Ivr1xua9rWr95XwnxJF4fJF98 AF18GF43Arn3WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbV8FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVWxJr 0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1lc2xSY4AK67AK6r4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvj DU0xZFpf9x0JUcAwxUUUUU= 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]); Sun, 03 Dec 2023 09:19:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784282068184644493 X-GMAIL-MSGID: 1784282068184644493 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 --- drivers/gpu/drm/radeon/sumo_dpm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c index f74f381af05f..bde640053708 100644 --- a/drivers/gpu/drm/radeon/sumo_dpm.c +++ b/drivers/gpu/drm/radeon/sumo_dpm.c @@ -1494,6 +1494,7 @@ static int sumo_parse_power_table(struct radeon_device *rdev) 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) + kfree(rdev->pm.dpm.ps); return -EINVAL; ps = kzalloc(sizeof(struct sumo_ps), GFP_KERNEL); if (ps == NULL) {