From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
To: "Cong Liu" <liucong2@kylinos.cn>,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86/amd/pmf: Fix memory leak in amd_pmf_get_pb_data()
Date: Tue, 23 Jan 2024 20:07:53 +0530 [thread overview]
Message-ID: <b7bd8769-5f97-4c9a-be80-8d1acac92b19@amd.com> (raw)
In-Reply-To: <20240123011147.6843-1-liucong2@kylinos.cn>
Hi,
On 1/23/2024 06:41, Cong Liu wrote:
> amd_pmf_get_pb_data() will allocate memory for the policy buffer,
> but does not free it if copy_from_user() fails. This leads to a memory
> leak.
Thank you for the fix and looks good to me (just a valid Fixes tag is
missing.)
Fixes: 10817f28e533 ("platform/x86/amd/pmf: Add capability to sideload
of policy binary")
Reviewed-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Thanks,
Shyam
>
> Signed-off-by: Cong Liu <liucong2@kylinos.cn>
> ---
> drivers/platform/x86/amd/pmf/tee-if.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
> index 502ce93d5cdd..f8c0177afb0d 100644
> --- a/drivers/platform/x86/amd/pmf/tee-if.c
> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
> @@ -298,8 +298,10 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
> if (!new_policy_buf)
> return -ENOMEM;
>
> - if (copy_from_user(new_policy_buf, buf, length))
> + if (copy_from_user(new_policy_buf, buf, length)) {
> + kfree(new_policy_buf);
> return -EFAULT;
> + }
>
> kfree(dev->policy_buf);
> dev->policy_buf = new_policy_buf;
next prev parent reply other threads:[~2024-01-23 14:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 1:11 Cong Liu
2024-01-23 14:37 ` Shyam Sundar S K [this message]
2024-01-24 1:29 ` [PATCH v2] " Cong Liu
2024-01-26 19:16 ` Hans de Goede
2024-01-28 10:45 ` [v2] " Markus Elfring
2024-01-29 8:59 ` Hans de Goede
2024-01-29 9:52 ` Markus Elfring
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=b7bd8769-5f97-4c9a-be80-8d1acac92b19@amd.com \
--to=shyam-sundar.s-k@amd.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liucong2@kylinos.cn \
--cc=platform-driver-x86@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
all inboxes | Powered by JetHome®