mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ACPI: property: Fix leaked buffers after skipped properties
@ 2026-11-12  9:09 raoxu
  2026-11-13 12:10 ` Sakari Ailus
  0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-11-12  9:09 UTC (permalink / raw)
  To: rafael; +Cc: lenb, sakari.ailus, linux-acpi, linux-kernel, raoxu, stable

From: Xu Rao <raoxu@uniontech.com>

acpi_data_add_buffer_props() compacts successfully parsed buffer
properties into an output package, but stores their separately allocated
evaluation buffers in props->bufs using the original input index.
acpi_free_device_properties() only frees entries below the output
package's successful-property count.

If a property is skipped because of an invalid format, invalid types or
a failed object evaluation, later successful entries can be stored past
the range visited during cleanup. For example, a failed first entry and
a successful second entry leave the allocation in bufs[1] while cleanup
only visits bufs[0]. The evaluation buffer is then leaked when the
properties are destroyed. Lists with no skipped entries do not exhibit
this mismatch.

Store each evaluation buffer at the current output count before
incrementing it. This keeps the ownership array compact and aligned with
the cleanup bound without changing property order or buffer contents.

Fixes: 103e10c69c61 ("ACPI: property: Add support for parsing buffer property UUID")
Signed-off-by: Xu Rao <raoxu@uniontech.com>
Cc: stable@vger.kernel.org
---
 drivers/acpi/property.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 8ee5a1f0eb48..fb6b214f2335 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -523,7 +523,7 @@ static void acpi_data_add_buffer_props(acpi_handle handle,
 		obj->buffer.length = buf_obj->buffer.length;
 		obj->buffer.pointer = buf_obj->buffer.pointer;

-		props->bufs[i] = buf.pointer;
+		props->bufs[*count] = buf.pointer;
 		package++;
 		(*count)++;
 	}
--
2.50.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI: property: Fix leaked buffers after skipped properties
  2026-11-12  9:09 [PATCH] ACPI: property: Fix leaked buffers after skipped properties raoxu
@ 2026-11-13 12:10 ` Sakari Ailus
  0 siblings, 0 replies; 2+ messages in thread
From: Sakari Ailus @ 2026-11-13 12:10 UTC (permalink / raw)
  To: raoxu; +Cc: rafael, lenb, linux-acpi, linux-kernel, stable

Hi Rao,

Thanks for the patch.

On Thu, Nov 12, 2026 at 05:09:54PM +0800, raoxu wrote:
> From: Xu Rao <raoxu@uniontech.com>
> 
> acpi_data_add_buffer_props() compacts successfully parsed buffer
> properties into an output package, but stores their separately allocated
> evaluation buffers in props->bufs using the original input index.
> acpi_free_device_properties() only frees entries below the output
> package's successful-property count.
> 
> If a property is skipped because of an invalid format, invalid types or
> a failed object evaluation, later successful entries can be stored past
> the range visited during cleanup. For example, a failed first entry and
> a successful second entry leave the allocation in bufs[1] while cleanup
> only visits bufs[0]. The evaluation buffer is then leaked when the
> properties are destroyed. Lists with no skipped entries do not exhibit
> this mismatch.
> 
> Store each evaluation buffer at the current output count before
> incrementing it. This keeps the ownership array compact and aligned with
> the cleanup bound without changing property order or buffer contents.
> 
> Fixes: 103e10c69c61 ("ACPI: property: Add support for parsing buffer property UUID")
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
> Cc: stable@vger.kernel.org

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> ---
>  drivers/acpi/property.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index 8ee5a1f0eb48..fb6b214f2335 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -523,7 +523,7 @@ static void acpi_data_add_buffer_props(acpi_handle handle,
>  		obj->buffer.length = buf_obj->buffer.length;
>  		obj->buffer.pointer = buf_obj->buffer.pointer;
> 
> -		props->bufs[i] = buf.pointer;
> +		props->bufs[*count] = buf.pointer;
>  		package++;
>  		(*count)++;
>  	}

-- 
Kind regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-13 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12  9:09 [PATCH] ACPI: property: Fix leaked buffers after skipped properties raoxu
2026-11-13 12:10 ` Sakari Ailus

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®