* [PATCH] ACPI/ACPICA: Check for NULL pointer after calling alloc
@ 2022-01-14 10:15 Jiasheng Jiang
2022-01-14 18:09 ` [Devel] " Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Jiasheng Jiang @ 2022-01-14 10:15 UTC (permalink / raw)
To: robert.moore, rafael.j.wysocki, lenb
Cc: linux-acpi, devel, linux-kernel, Jiasheng Jiang
As the possible failure of the allocation, object_info could be NULL
pointer.
Therefore, it should be better to check it in order to avoid the
dereference of the NULL pointer.
If fails, we should return 'AE_NON_MEMORY' and the caller
acpi_db_command_dispatch() will deal with the return status of
acpi_db_display_objects().
Also, the comment of the acpi_db_display_objects() is wrong.
So we need to correct it too.
Fixes: 995751025572 ("ACPICA: Linuxize: Export debugger files to Linux")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/acpi/acpica/dbnames.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
index 3615e1a6efd8..d8e5852fadb1 100644
--- a/drivers/acpi/acpica/dbnames.c
+++ b/drivers/acpi/acpica/dbnames.c
@@ -632,7 +632,7 @@ acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
* PARAMETERS: obj_type_arg - Type of object to display
* display_count_arg - Max depth to display
*
- * RETURN: None
+ * RETURN: Status
*
* DESCRIPTION: Display objects in the namespace of the requested type
*
@@ -651,6 +651,8 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
if (!obj_type_arg) {
object_info =
ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
+ if (!object_info)
+ return (AE_NO_MEMORY);
/* Walk the namespace from the root */
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI/ACPICA: Check for NULL pointer after calling alloc
@ 2022-01-14 18:09 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-01-14 18:09 UTC (permalink / raw)
To: Jiasheng Jiang
Cc: Robert Moore, Rafael Wysocki, Len Brown, ACPI Devel Maling List,
open list:ACPI COMPONENT ARCHITECTURE (ACPICA),
Linux Kernel Mailing List
On Fri, Jan 14, 2022 at 11:16 AM Jiasheng Jiang <jiasheng@iscas.ac.cn> wrote:
>
> As the possible failure of the allocation, object_info could be NULL
> pointer.
> Therefore, it should be better to check it in order to avoid the
> dereference of the NULL pointer.
> If fails, we should return 'AE_NON_MEMORY' and the caller
> acpi_db_command_dispatch() will deal with the return status of
> acpi_db_display_objects().
> Also, the comment of the acpi_db_display_objects() is wrong.
> So we need to correct it too.
>
> Fixes: 995751025572 ("ACPICA: Linuxize: Export debugger files to Linux")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
This is ACPICA material, so it needs to be submitted to the upstream
ACPICA project via https://github.com/acpica/acpica, thanks!
> ---
> drivers/acpi/acpica/dbnames.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
> index 3615e1a6efd8..d8e5852fadb1 100644
> --- a/drivers/acpi/acpica/dbnames.c
> +++ b/drivers/acpi/acpica/dbnames.c
> @@ -632,7 +632,7 @@ acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
> * PARAMETERS: obj_type_arg - Type of object to display
> * display_count_arg - Max depth to display
> *
> - * RETURN: None
> + * RETURN: Status
> *
> * DESCRIPTION: Display objects in the namespace of the requested type
> *
> @@ -651,6 +651,8 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
> if (!obj_type_arg) {
> object_info =
> ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
> + if (!object_info)
> + return (AE_NO_MEMORY);
>
> /* Walk the namespace from the root */
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Devel] Re: [PATCH] ACPI/ACPICA: Check for NULL pointer after calling alloc
@ 2022-01-14 18:09 ` Rafael J. Wysocki
0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-01-14 18:09 UTC (permalink / raw)
To: devel
[-- Attachment #1: Type: text/plain, Size: 1877 bytes --]
On Fri, Jan 14, 2022 at 11:16 AM Jiasheng Jiang <jiasheng(a)iscas.ac.cn> wrote:
>
> As the possible failure of the allocation, object_info could be NULL
> pointer.
> Therefore, it should be better to check it in order to avoid the
> dereference of the NULL pointer.
> If fails, we should return 'AE_NON_MEMORY' and the caller
> acpi_db_command_dispatch() will deal with the return status of
> acpi_db_display_objects().
> Also, the comment of the acpi_db_display_objects() is wrong.
> So we need to correct it too.
>
> Fixes: 995751025572 ("ACPICA: Linuxize: Export debugger files to Linux")
> Signed-off-by: Jiasheng Jiang <jiasheng(a)iscas.ac.cn>
This is ACPICA material, so it needs to be submitted to the upstream
ACPICA project via https://github.com/acpica/acpica, thanks!
> ---
> drivers/acpi/acpica/dbnames.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
> index 3615e1a6efd8..d8e5852fadb1 100644
> --- a/drivers/acpi/acpica/dbnames.c
> +++ b/drivers/acpi/acpica/dbnames.c
> @@ -632,7 +632,7 @@ acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
> * PARAMETERS: obj_type_arg - Type of object to display
> * display_count_arg - Max depth to display
> *
> - * RETURN: None
> + * RETURN: Status
> *
> * DESCRIPTION: Display objects in the namespace of the requested type
> *
> @@ -651,6 +651,8 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
> if (!obj_type_arg) {
> object_info =
> ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
> + if (!object_info)
> + return (AE_NO_MEMORY);
>
> /* Walk the namespace from the root */
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-14 18:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 10:15 [PATCH] ACPI/ACPICA: Check for NULL pointer after calling alloc Jiasheng Jiang
2022-01-14 18:09 ` Rafael J. Wysocki
2022-01-14 18:09 ` [Devel] " Rafael J. Wysocki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.