Linux ACPI
 help / color / mirror / Atom feed
* [PATCH 1/1] acpi: check return value of acpi_os_map_memory
@ 2013-10-28  6:04 RUC_SoftSec
  2013-10-28 11:01 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: RUC_SoftSec @ 2013-10-28  6:04 UTC (permalink / raw)
  To: Len Brown, Rafael J. Wysocki; +Cc: linux-acpi, linux-kernel, RUC_SoftSec

Function acpi_os_map_memory() may return a NULL pointer, it should be validated non-NULL before used.
This bug is found by a static tool developed by RUC_SoftSec, supported by China.X.Orion.

Signed-off-by: RUC_SoftSec <rucsoftsec@gmail.com>
---
 drivers/acpi/osl.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index e5f416c..bf8f93f 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -717,6 +717,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table,
 
 		table = acpi_os_map_memory(acpi_tables_addr + table_offset,
 					   ACPI_HEADER_SIZE);
+		if (table == NULL)
+			return AE_OK;
 
 		if (table_offset + table->length > all_tables_size) {
 			acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
-- 
1.7.9.5

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

* Re: [PATCH 1/1] acpi: check return value of acpi_os_map_memory
  2013-10-28  6:04 [PATCH 1/1] acpi: check return value of acpi_os_map_memory RUC_SoftSec
@ 2013-10-28 11:01 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2013-10-28 11:01 UTC (permalink / raw)
  To: RUC_SoftSec; +Cc: Len Brown, linux-acpi, linux-kernel

On Monday, October 28, 2013 02:04:19 PM RUC_SoftSec wrote:
> Function acpi_os_map_memory() may return a NULL pointer, it should be validated non-NULL before used.
> This bug is found by a static tool developed by RUC_SoftSec, supported by China.X.Orion.
> 
> Signed-off-by: RUC_SoftSec <rucsoftsec@gmail.com>
> ---
>  drivers/acpi/osl.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
> index e5f416c..bf8f93f 100644
> --- a/drivers/acpi/osl.c
> +++ b/drivers/acpi/osl.c
> @@ -717,6 +717,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table,
>  
>  		table = acpi_os_map_memory(acpi_tables_addr + table_offset,
>  					   ACPI_HEADER_SIZE);
> +		if (table == NULL)

"if (!table)" perhaps?

> +			return AE_OK;

And why is it a good idea to return success then?

>  
>  		if (table_offset + table->length > all_tables_size) {
>  			acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
> 

Thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

end of thread, other threads:[~2013-10-28 10:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-28  6:04 [PATCH 1/1] acpi: check return value of acpi_os_map_memory RUC_SoftSec
2013-10-28 11:01 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox