Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2901594rdb; Mon, 4 Dec 2023 10:30:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvlh2PxP1nI+i9OhPJ8/inEeLXeYfdVJKenuj05lFCAjcwbhNcL3RSOwKtr+CES9dUBiLc X-Received: by 2002:a17:903:22cb:b0:1d0:8db6:17d0 with SMTP id y11-20020a17090322cb00b001d08db617d0mr1703217plg.25.1701714602340; Mon, 04 Dec 2023 10:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701714602; cv=none; d=google.com; s=arc-20160816; b=xZxUXMiyEogBGW2dDtbsrnptEpDPAH0T4YDq8IKtSfos2OMf2OONDHraDCJgAxMhKe CZcKSNpjk0RgJks3BTrmnuALwLZK6hTHU/0YKl45vS/T7+9nOQCrhEwy/V9b9J8xB7Z/ 6v0CBQib0KKZEC8JJMK+aoJFw+RyYs8vTnUv+3YhePasPA8jaqW/UcBq7b01IkPBuPus U7WINaVqAkQREMl+aKkWRxJYcWQrDyg1nILFIvEfZv6U4D94uV+pz3Sb2kBVVgr7Ek4d 24US0O1z9VW2XdLl4vY8eWWWl1CuPK57NeHi9CjrPC88Q489fhM43WmbXZz9PK/B/em+ qV5w== 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=Q98w33mc6+s9A9wtHHFHE8JJnBQGyFexGo0rxM7RDmY=; fh=58SjfS76T0oFVThFMo+3pZG33P29w/Ck8YUXcVM5qxg=; b=AqoqB24gFq0nMY7kT2KegIWOkoyL+XwJ1IFWv/XkQZeGqXZBZxBgb7PGA9PXBWRjX/ ql9c9Txtk76J0pzsVOMrEMWv870s9fYjhPIsNyhjrHXr0pmLrCY8ekiDVKxNeZbanKlo 52hSx8WI94Z/+6g++n7CUd6Nn6LbSCPDgxLa3zfbRjWuV1Kg/f5sCzcMkXh324EeAJWb gV7OWLaqVcfCdCGs8d780CHNhXzRR9P6Uv/i2ANFgQTSv8jETZEYS/E00JgPFHZL8e6G razbSC/mX2sAqyDR+DnfwhEVzGZtM1pqnP+NvB9ZNXxkeFIRDygUviaWnkQPrsahBPi0 7vSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=adMW4sx+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id i18-20020a170902c95200b001cfec9dcd7fsi550859pla.408.2023.12.04.10.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:30:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=adMW4sx+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 192AC8051AA6; Mon, 4 Dec 2023 10:29:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbjLDS3p (ORCPT + 99 others); Mon, 4 Dec 2023 13:29:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbjLDS3n (ORCPT ); Mon, 4 Dec 2023 13:29:43 -0500 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCFC1FF for ; Mon, 4 Dec 2023 10:29:49 -0800 (PST) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-1fadb9ac169so2653554fac.0 for ; Mon, 04 Dec 2023 10:29:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701714589; x=1702319389; 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=Q98w33mc6+s9A9wtHHFHE8JJnBQGyFexGo0rxM7RDmY=; b=adMW4sx+sMTUUaH8g8KeV7Y9HQU5IrbGSTcTQ2dY4TwIZs8p2Zmm0jSPIY3uYvuDzI i3UfBIpBCV4N2tRSv0IOrIlUaQqqIjOeRmwyyTQbS/JSwRrAqhGnWm+ZoyNiNXVhq/PJ khhF/i17txXEP934K04X5AaxBEsmLCelwqcFLLHsjYYLQtvRKHso6LRIImEhzwZjPxTW 5ZrdVVG9LfP0CsxJLcfXMHjh0UoZaO1gRDg0737PeUcFPGOfPq9LQmMbwZZYIbDUgv53 JXlDPIYdER5fdx9+YKjm4eML/gjrc13cIb3ChCZSuL/on/YrrsedWGbsPn30H+oBuKDv Fj7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701714589; x=1702319389; 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=Q98w33mc6+s9A9wtHHFHE8JJnBQGyFexGo0rxM7RDmY=; b=U/Am1lA3A1K9S3bCsiaXTGevoWtM6aBaQOpUqhh5fzpi82xvH3FC7K03mQrgGIPOUq 15uqMrYt9jXZsLaBrIEeptOu0y7yrSEcMxCkPWCjDRiH7muAMFT/ddm3reE/WXmdULRu 0Y+1MvqJhAQW/ghv4CNpwuZ98MGW/QpNCzIPFW/978Qk9YFjW9jNv6hw6efRLB9r0Lf8 UCiiXe83nkh774/KoUsraL8X5+Bc5aXjfiaJ3Fgxcv7S2vIIgA3lh3SukE88UzKQpPfG sSbSoOazIVVXr+S6D91l4iHePRV8a5WXCoGhKuY9ZWTecyNH/GiBWItYdzzjG5x/CjXP BnmQ== X-Gm-Message-State: AOJu0Yxfs3/7527CWY1g3cIQ/GbIYWwKBbuLp4R1YavHyshV3r8CKGQN ExDssCUH6AcOZyX1+vQHEHG8tlY4fphvu1Pzo3c= X-Received: by 2002:a05:6870:7813:b0:1fa:1ca3:ced8 with SMTP id hb19-20020a056870781300b001fa1ca3ced8mr2735574oab.52.1701714589221; Mon, 04 Dec 2023 10:29:49 -0800 (PST) MIME-Version: 1.0 References: <20231204102154.3309670-1-alexious@zju.edu.cn> In-Reply-To: <20231204102154.3309670-1-alexious@zju.edu.cn> From: Alex Deucher Date: Mon, 4 Dec 2023 13:29:38 -0500 Message-ID: Subject: Re: [PATCH] [v2] drm/radeon/trinity_dpm: fix a memleak in trinity_parse_power_table To: Zhipeng Lu Cc: "Pan, Xinhui" , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 10:29:59 -0800 (PST) Applied. Thanks! On Mon, Dec 4, 2023 at 5:39=E2=80=AFAM Zhipeng Lu wro= te: > > 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/radeo= n/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 =3D power_state->v2.nonClockInfoInd= ex; > non_clock_info =3D (struct _ATOM_PPLIB_NONCLOCK_INFO *) > &non_clock_info_array->nonClockInfo[non_clock_arr= ay_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 =3D kzalloc(sizeof(struct sumo_ps), GFP_KERNEL); > if (ps =3D=3D NULL) { > kfree(rdev->pm.dpm.ps); > -- > 2.34.1 >