* [PATCH] vfio/platform: Remove the ACPI buffer memory to fix memory leak
@ 2022-11-22 11:29 Hanjun Guo
2022-11-23 8:41 ` Eric Auger
2022-11-29 19:52 ` Alex Williamson
0 siblings, 2 replies; 4+ messages in thread
From: Hanjun Guo @ 2022-11-22 11:29 UTC (permalink / raw)
To: Eric Auger, Alex Williamson; +Cc: kvm, linux-kernel, Sinan Kaya, Hanjun Guo
The ACPI buffer memory (buffer.pointer) returned by acpi_evaluate_object()
is not used after the call of _RST method, so it leads to memory leak.
For the calling of ACPI _RST method, we don't need to pass a buffer
for acpi_evaluate_object(), we can just pass NULL and remove the ACPI
buffer memory in vfio_platform_acpi_call_reset(), then we don't need to
free the memory and no memory leak.
Fixes: d30daa33ec1d ("vfio: platform: call _RST method when using ACPI")
Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
drivers/vfio/platform/vfio_platform_common.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
index 55dc4f4..1a0a238 100644
--- a/drivers/vfio/platform/vfio_platform_common.c
+++ b/drivers/vfio/platform/vfio_platform_common.c
@@ -72,12 +72,11 @@ static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev,
const char **extra_dbg)
{
#ifdef CONFIG_ACPI
- struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct device *dev = vdev->device;
acpi_handle handle = ACPI_HANDLE(dev);
acpi_status acpi_ret;
- acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, &buffer);
+ acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, NULL);
if (ACPI_FAILURE(acpi_ret)) {
if (extra_dbg)
*extra_dbg = acpi_format_exception(acpi_ret);
--
1.7.12.4
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] vfio/platform: Remove the ACPI buffer memory to fix memory leak
2022-11-22 11:29 [PATCH] vfio/platform: Remove the ACPI buffer memory to fix memory leak Hanjun Guo
@ 2022-11-23 8:41 ` Eric Auger
2022-11-29 19:52 ` Alex Williamson
1 sibling, 0 replies; 4+ messages in thread
From: Eric Auger @ 2022-11-23 8:41 UTC (permalink / raw)
To: Hanjun Guo, Alex Williamson; +Cc: kvm, linux-kernel, Sinan Kaya
Hi,
On 11/22/22 12:29, Hanjun Guo wrote:
> The ACPI buffer memory (buffer.pointer) returned by acpi_evaluate_object()
> is not used after the call of _RST method, so it leads to memory leak.
>
> For the calling of ACPI _RST method, we don't need to pass a buffer
> for acpi_evaluate_object(), we can just pass NULL and remove the ACPI
> buffer memory in vfio_platform_acpi_call_reset(), then we don't need to
> free the memory and no memory leak.
>
> Fixes: d30daa33ec1d ("vfio: platform: call _RST method when using ACPI")
> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
> ---
> drivers/vfio/platform/vfio_platform_common.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
> index 55dc4f4..1a0a238 100644
> --- a/drivers/vfio/platform/vfio_platform_common.c
> +++ b/drivers/vfio/platform/vfio_platform_common.c
> @@ -72,12 +72,11 @@ static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev,
> const char **extra_dbg)
> {
> #ifdef CONFIG_ACPI
> - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
> struct device *dev = vdev->device;
> acpi_handle handle = ACPI_HANDLE(dev);
> acpi_status acpi_ret;
>
> - acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, &buffer);
> + acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, NULL);
> if (ACPI_FAILURE(acpi_ret)) {
> if (extra_dbg)
> *extra_dbg = acpi_format_exception(acpi_ret);
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thank you for the fix!
Eric
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] vfio/platform: Remove the ACPI buffer memory to fix memory leak
2022-11-22 11:29 [PATCH] vfio/platform: Remove the ACPI buffer memory to fix memory leak Hanjun Guo
2022-11-23 8:41 ` Eric Auger
@ 2022-11-29 19:52 ` Alex Williamson
2022-11-30 1:20 ` Hanjun Guo
1 sibling, 1 reply; 4+ messages in thread
From: Alex Williamson @ 2022-11-29 19:52 UTC (permalink / raw)
To: Hanjun Guo; +Cc: Eric Auger, kvm, linux-kernel, Sinan Kaya
On Tue, 22 Nov 2022 19:29:58 +0800
Hanjun Guo <guohanjun@huawei.com> wrote:
> The ACPI buffer memory (buffer.pointer) returned by acpi_evaluate_object()
> is not used after the call of _RST method, so it leads to memory leak.
>
> For the calling of ACPI _RST method, we don't need to pass a buffer
> for acpi_evaluate_object(), we can just pass NULL and remove the ACPI
> buffer memory in vfio_platform_acpi_call_reset(), then we don't need to
> free the memory and no memory leak.
>
> Fixes: d30daa33ec1d ("vfio: platform: call _RST method when using ACPI")
> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
> ---
> drivers/vfio/platform/vfio_platform_common.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
> index 55dc4f4..1a0a238 100644
> --- a/drivers/vfio/platform/vfio_platform_common.c
> +++ b/drivers/vfio/platform/vfio_platform_common.c
> @@ -72,12 +72,11 @@ static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev,
> const char **extra_dbg)
> {
> #ifdef CONFIG_ACPI
> - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
> struct device *dev = vdev->device;
> acpi_handle handle = ACPI_HANDLE(dev);
> acpi_status acpi_ret;
>
> - acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, &buffer);
> + acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, NULL);
> if (ACPI_FAILURE(acpi_ret)) {
> if (extra_dbg)
> *extra_dbg = acpi_format_exception(acpi_ret);
An identical change was already posted and accepted into the vfio next
branch, see:
https://lore.kernel.org/all/20221018152825.891032-1-rafaelmendsr@gmail.com/
In linux-next as:
e67e070632a6 ("vfio: platform: Do not pass return buffer to ACPI _RST method")
Thanks,
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] vfio/platform: Remove the ACPI buffer memory to fix memory leak
2022-11-29 19:52 ` Alex Williamson
@ 2022-11-30 1:20 ` Hanjun Guo
0 siblings, 0 replies; 4+ messages in thread
From: Hanjun Guo @ 2022-11-30 1:20 UTC (permalink / raw)
To: Alex Williamson; +Cc: Eric Auger, kvm, linux-kernel, Sinan Kaya
On 2022/11/30 3:52, Alex Williamson wrote:
> On Tue, 22 Nov 2022 19:29:58 +0800
> Hanjun Guo <guohanjun@huawei.com> wrote:
>
>> The ACPI buffer memory (buffer.pointer) returned by acpi_evaluate_object()
>> is not used after the call of _RST method, so it leads to memory leak.
>>
>> For the calling of ACPI _RST method, we don't need to pass a buffer
>> for acpi_evaluate_object(), we can just pass NULL and remove the ACPI
>> buffer memory in vfio_platform_acpi_call_reset(), then we don't need to
>> free the memory and no memory leak.
>>
>> Fixes: d30daa33ec1d ("vfio: platform: call _RST method when using ACPI")
>> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
>> ---
>> drivers/vfio/platform/vfio_platform_common.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
>> index 55dc4f4..1a0a238 100644
>> --- a/drivers/vfio/platform/vfio_platform_common.c
>> +++ b/drivers/vfio/platform/vfio_platform_common.c
>> @@ -72,12 +72,11 @@ static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev,
>> const char **extra_dbg)
>> {
>> #ifdef CONFIG_ACPI
>> - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
>> struct device *dev = vdev->device;
>> acpi_handle handle = ACPI_HANDLE(dev);
>> acpi_status acpi_ret;
>>
>> - acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, &buffer);
>> + acpi_ret = acpi_evaluate_object(handle, "_RST", NULL, NULL);
>> if (ACPI_FAILURE(acpi_ret)) {
>> if (extra_dbg)
>> *extra_dbg = acpi_format_exception(acpi_ret);
>
> An identical change was already posted and accepted into the vfio next
> branch, see:
>
> https://lore.kernel.org/all/20221018152825.891032-1-rafaelmendsr@gmail.com/
>
> In linux-next as:
>
> e67e070632a6 ("vfio: platform: Do not pass return buffer to ACPI _RST method")
Thanks, I missed this patch, please drop this one.
Thanks
Hanjun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-30 1:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 11:29 [PATCH] vfio/platform: Remove the ACPI buffer memory to fix memory leak Hanjun Guo
2022-11-23 8:41 ` Eric Auger
2022-11-29 19:52 ` Alex Williamson
2022-11-30 1:20 ` Hanjun Guo
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®