Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3388157rdh; Mon, 27 Nov 2023 13:00:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlUIB76qshYZCUfPu7kEC1n3iefIPMWafcg3bPGJJmE8ZJ8PrFNYDK359YJvDOEkGVQmFP X-Received: by 2002:a05:6830:1395:b0:6d8:17b:d08c with SMTP id d21-20020a056830139500b006d8017bd08cmr15009965otq.27.1701118802567; Mon, 27 Nov 2023 13:00:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701118802; cv=none; d=google.com; s=arc-20160816; b=TZsbZtjOhGDepAX+V1gAGKLI3bFN/m+At/J2lF5OhWuJTiXihXi5guTtlx6yr2uoPU xkEKyrR2HRJ11/V0WvoYulP25T5inXRDcFkqSxC8L5mBTg0YAKk9hfBOWXOXYpmoA6gv 9/yiw5Q05XlzYJsQ/3A1oJxhyePtnndd+m3GJGY6qdmKZymYugAt4fwVpHizSjRlt1x0 Y+gVL/g4+QoMXVkgnbSDRhNxS2CYzAu3OWHAI+I45J0ecFieiBT5VO+w8+WgFytcpUtL TEqnvd0E63IqO4JFysVA9zdLZQITLVanpuvDiC5Hcvmuy75G+KNWm1uBI34wv0UJrVNw 99fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=X3yo837GDz7kubNtzjO6WNlCk3oHXeJlohNg0iLQ45k=; fh=pRJIJT4LUEztnuKcjZJQ6JmDuiAPGnL5VaXdWQ1rV6w=; b=ruq7n2TLzEb9Ft+l7hLpCRIKK1cPJZzc+qJ9Q+2bEwNYEZTB4pjm6Sq7f1ZQl/TfF0 DWQPZlC0ht8VWZsPPhEDYpWfoghw+sJcZy7oaaVoM4O2Xxx/14WJKW4vVM9HmusVcNSd TGgFd++AQWbsBSTylO2X4f/MPhZ6+e2uOqXzZkb0N1zU0E3DCk4+ck2foeqTEPy6ccuz MuNviRqmgVsN8xoLCkteCOAR7woD2MIr41ugnsHY+ZAgx+QxaozAnqwcFB4Y6sLJZph0 drsgFwsMclClxveJRtwulSTe0BmHVIBI0VOI1PxyZyUH67ttCMUyXiUrHbyYleaOxuB6 5z2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="CvC/iO+Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z14-20020a63190e000000b00578bb009dd1si10642644pgl.809.2023.11.27.13.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 13:00:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="CvC/iO+Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1B9F280687F6; Mon, 27 Nov 2023 13:00:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231190AbjK0U7p (ORCPT + 99 others); Mon, 27 Nov 2023 15:59:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjK0U7o (ORCPT ); Mon, 27 Nov 2023 15:59:44 -0500 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E7E9C0 for ; Mon, 27 Nov 2023 12:59:51 -0800 (PST) Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6d64c1155a8so3163610a34.2 for ; Mon, 27 Nov 2023 12:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701118790; x=1701723590; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=X3yo837GDz7kubNtzjO6WNlCk3oHXeJlohNg0iLQ45k=; b=CvC/iO+Y7QCjxOEWQAHJxONR7ZmESQRn75AgGPzE8i8GW/Q+x+nandEGyVWgZ1bbkE i9SM3fTNkFIzag0w1k0T6qAs+FQUidhNeT1gBrDuNtiRmiwDeE8JSIrqzhOdNd0ZTJGI ly7VBrYphtqifo1NKoytadumaO5wnxCOpWNsXR47wrDEk6vjXZ3kWkex2W/WlGPLTuRE Tdfm1N4Vt1MejrVIPKNj4jsh5C1w9mFTP6KhDwmQoBAmU/m+rWgs0Kw0x4boy0SCpE1M Amch7BYAf2qbWbZCLnoRKm33EfN4cKqAinMQIuDrMKp1k6GKHpeS8RIGlmIFXsktXJf0 kGLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701118790; x=1701723590; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X3yo837GDz7kubNtzjO6WNlCk3oHXeJlohNg0iLQ45k=; b=f3hq7O/N0QGu7bL8OWyO2Huz6m1y9k5XWALutrzY8peHIIFwT1IQ0lpcsCcynwoL7N fmUNeOqYNgOOGps580D02Uh/AuntQIdm1vUGQrW1i1jGgnPNFIklIgiWC+coC0JV43fO KSO3biDMveyhHUiQeU0iZ58y7+gXoKH4Q9FqFFYwH8P7i2oByZ7cSLX22NLwgULc4byD +7aYjcWHaLQHkoAaFfIp7ZjnlWDfvcnqmENzIYoMD0T0W3ZNFFlpcgPY5shFED5a4Ccc XUR9mHTsiuYYN0RJZ2ZZEnTYo3JMLTACWlF/qXZ0Bgv7J+h8JOdxlrAWGhLkKBpWkhrn T8kg== X-Gm-Message-State: AOJu0Yx9mihqLemgIIL46bxt/8L24eQMFudQlc0VDkfnHTYCXbUxlWfN 71cPEWQr6qV7s286/OnxEqLH+83r0GBMqvtWnnY= X-Received: by 2002:a05:6870:3c8b:b0:1f9:dc5a:b8fc with SMTP id gl11-20020a0568703c8b00b001f9dc5ab8fcmr17780453oab.56.1701118790494; Mon, 27 Nov 2023 12:59:50 -0800 (PST) MIME-Version: 1.0 References: <20231123073325.16843-1-dinghao.liu@zju.edu.cn> In-Reply-To: <20231123073325.16843-1-dinghao.liu@zju.edu.cn> From: Alex Deucher Date: Mon, 27 Nov 2023 15:59:39 -0500 Message-ID: Subject: Re: [PATCH] drm/amd/pm: fix a memleak in aldebaran_tables_init To: Dinghao Liu Cc: Yifan Zhang , Lijo Lazar , Yang Wang , dri-devel@lists.freedesktop.org, "Pan, Xinhui" , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Le Ma , "Stanley.Yang" , Mario Limonciello , Darren Powell , Alex Deucher , Evan Quan , =?UTF-8?Q?Christian_K=C3=B6nig?= , Hawking Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 27 Nov 2023 13:00:00 -0800 (PST) Applied. Thanks! On Thu, Nov 23, 2023 at 3:08=E2=80=AFAM Dinghao Liu wrote: > > 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 =3D 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 >