From: "Christian König" <christian.koenig@amd.com>
To: Zhipeng Lu <alexious@zju.edu.cn>
Cc: Alex Deucher <alexander.deucher@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Jerome Glisse <jglisse@redhat.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/radeon/dpm: fix a memleak in sumo_parse_power_table
Date: Mon, 4 Dec 2023 09:17:08 +0100 [thread overview]
Message-ID: <b1fa2827-61fb-4594-8f80-e5083be8d5fa@amd.com> (raw)
In-Reply-To: <20231203171643.3287229-1-alexious@zju.edu.cn>
Am 03.12.23 um 18:16 schrieb Zhipeng Lu:
> 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 <alexious@zju.edu.cn>
> ---
> 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;
That change is obviously not correct since you now always return -EINVAL.
You need to at least add {} here.
Regards,
Christian.
> ps = kzalloc(sizeof(struct sumo_ps), GFP_KERNEL);
> if (ps == NULL) {
next prev parent reply other threads:[~2023-12-04 8:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-03 17:16 [PATCH] drm/radeon/dpm: fix a memleak in sumo_parse_power_table Zhipeng Lu
2023-12-04 8:17 ` Christian König [this message]
2023-12-04 8:46 ` alexious
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b1fa2827-61fb-4594-8f80-e5083be8d5fa@amd.com \
--to=christian.koenig@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=alexious@zju.edu.cn \
--cc=amd-gfx@lists.freedesktop.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jglisse@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox