Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp163583rdh; Wed, 22 Nov 2023 23:35:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqwRTs+SuHeLCYWw5JE4JRGQ8nbQNO8LWmxiJJa0cM8jC+Z6GHI5vlWOLZ/UXW7KYz60mr X-Received: by 2002:a05:6a20:8e02:b0:188:2637:9242 with SMTP id y2-20020a056a208e0200b0018826379242mr4988519pzj.47.1700724918500; Wed, 22 Nov 2023 23:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700724918; cv=none; d=google.com; s=arc-20160816; b=o9jGnk9tMlBISpFNV6nLNw4nPVdXkXzM8Dd/Kkn+gvntj1hHDStv7VFwdSJRXBdT9W jpiUyHCATvstp5iOkkLryQpFDjrFh1wAUuyNOLDk3jIj8aQGbPX6jSZIMy4hyKBUhArK EN/RpYm4Fi27aarGOHNs2J7f+pVj3ia9RWsYNv5i/7VDgFsZFXv9yO6STQf3u+8usrBw 5aUMbtLeUpIE1ODtUxu87SUVJZboRmQNgquPv5wDmnlvzPZX+YeX077TU8fJjueuJ+t1 1kj1g7Kq3Lk3J6EmxouVccegrUAOMv+gk8rdsgERI84+zktikII4lX6AOGcvVUfR7K7v xXGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=1PL8Il+z40271SvmJihHW3I9mJ3oWdxvUgynAP8UiIA=; fh=IZh5rr4xFl8XTvBxAt7LPBWiPEMFGhSCLICIg7Yt0ZA=; b=Ml9a45K+J2PgfpIXLUkozgUV8edFWHahefuVsNEIU7yYae9H5x+9JTOLD5MPtEEFew dcEh5GCkOae2JEFVbV9mU+W+bdjTiv64TrkqPaqnzxpq8C5WDPJgm8GwFA1gmtEgVJ70 /EeGlS06a44utJHWXvBPVlDMkSTgtu/UCiUEA+n/x/K8D0RDCOhW8qs2p5wB6u+oW2yS FTaO6QWhhVxeVzgf0axxAngUYiBsx6bYWEXePbAfHzVaK4inzLJSXr6FdSez8IxDJGW7 f/3i74b81ufgkbcU6fYnHRpnqwwEGSSrwAg/jNJPfRaXuLWE2cDlB/9WnJVOWvSt+CCn DjMw== 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:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id f19-20020a056a00229300b006cb4f0aaec6si767786pfe.232.2023.11.22.23.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 23:35:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 3F6AA8078E31; Wed, 22 Nov 2023 23:35:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344886AbjKWHep (ORCPT + 99 others); Thu, 23 Nov 2023 02:34:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344879AbjKWHem (ORCPT ); Thu, 23 Nov 2023 02:34:42 -0500 Received: from zg8tndyumtaxlji0oc4xnzya.icoremail.net (zg8tndyumtaxlji0oc4xnzya.icoremail.net [46.101.248.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BE8CED48 for ; Wed, 22 Nov 2023 23:34:44 -0800 (PST) Received: from localhost.localdomain (unknown [10.190.64.46]) by mail-app3 (Coremail) with SMTP id cC_KCgB3OOBjAF9l5MF0AQ--.22860S4; Thu, 23 Nov 2023 15:34:02 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn Cc: Evan Quan , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Lijo Lazar , Mario Limonciello , Darren Powell , Yang Wang , Yifan Zhang , Le Ma , Hawking Zhang , "Stanley.Yang" , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/amd/pm: fix a memleak in aldebaran_tables_init Date: Thu, 23 Nov 2023 15:33:22 +0800 Message-Id: <20231123073325.16843-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cC_KCgB3OOBjAF9l5MF0AQ--.22860S4 X-Coremail-Antispam: 1UD129KBjvdXoW7JFW7trW3uFW3WFy5Jr18Krg_yoWDurc_Wr y8X3sxZ3s5JFyDJF12yFsIqFyI9an3ur1kJw1vqasIgr1UJr48urW2qF1kuw4fZF17AF4q q3WkWw1rZrsxJjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbskFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AK wVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20x vE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4UJVW0owA2z4x0Y4vEx4A2 jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52 x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWU GwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI4 8JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2xKxwCF04k20xvY 0x0EwIxGrwCF04k20xvE74AGY7Cv6cx26r4fKr1UJr1l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr 1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE 14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7 IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E 87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73Uj IFyTuYvjfUoOJ5UUUUU X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgkMBmVKSCoDUABdsC 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 pete.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 (pete.vger.email [0.0.0.0]); Wed, 22 Nov 2023 23:35:16 -0800 (PST) When kzalloc() for smu_table->ecc_table fails, we should free the previously allocated resources to prevent memleak. Fixes: edd794208555 ("drm/amd/pm: add message smu to get ecc_table v2") Signed-off-by: Dinghao Liu --- drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c index 1a6675d70a4b..f1440869d1ce 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c @@ -257,8 +257,11 @@ static int aldebaran_tables_init(struct smu_context *smu) } smu_table->ecc_table = kzalloc(tables[SMU_TABLE_ECCINFO].size, GFP_KERNEL); - if (!smu_table->ecc_table) + if (!smu_table->ecc_table) { + kfree(smu_table->metrics_table); + kfree(smu_table->gpu_metrics_table); return -ENOMEM; + } return 0; } -- 2.17.1