drivers/acpi/processor_idle: check the return value of acpi_fetch_acpi_dev()
PATCH 1/1 drivers/acpi/processor_idle: check the return value of acpi_fetch_acpi_dev()
The return value of acpi_fetch_acpi_dev() could be NULL, which will cause null pointer dereference if used in acpi_device_hid().
--- drivers/acpi/processor_idle.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/processor_idle.c +2 -0
@@ -1117,6 +1117,8 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr) status =acpi_get_parent (handle, &pr_ahandle);while (ACPI_SUCCESS (status)) { d =acpi_fetch_acpi_dev (pr_ahandle); +if (!d) +break ; handle = pr_ahandle;if (strcmp (acpi_device_hid (d),ACPI_PROCESSOR_CONTAINER_HID ))
Signature · 1 line
2.25.1
Rafael J. Wysocki
maintainerQuoted 3 lines · Li Zhong
The return value of
acpi_fetch_acpi_dev()could be NULL, which will cause null pointer dereference if used inacpi_device_hid().
That's true.
Quoted 10 lines
Signed-off-by Li Zhong <[email protected]>--- drivers/acpi/processor_idle.c | 2 ++ 1 file changed, 2 insertions(+)drivers/acpi/processor_idle.c +0
-0
drivers/acpi/processor_idle.c static int acpi_processor_get_lpi_info(struct acpi_processor *pr) · line 1121
Quoted 5 lines
drivers/acpi/processor_idle.c +2
-0@@ -1117,6 +1117,8 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr) status =acpi_get_parent (handle, &pr_ahandle);while (ACPI_SUCCESS (status)) { d =acpi_fetch_acpi_dev (pr_ahandle); +if (!d) +break ;
But shouldn't this be continue?
Quoted 6 lines
drivers/acpi/processor_idle.c +0
-1handle = pr_ahandle;if (strcmp (acpi_device_hid (d),ACPI_PROCESSOR_CONTAINER_HID )) --2.25.1
Quoted 13 lines · Rafael J. Wysocki
Quoted 3 lines · Li Zhong
The return value of
acpi_fetch_acpi_dev()could be NULL, which will cause null pointer dereference if used inacpi_device_hid().That's true.
Quoted 5 lines
Signed-off-by Li Zhong <[email protected]>--- drivers/acpi/processor_idle.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 13 lines
drivers/acpi/processor_idle.c static int acpi_processor_get_lpi_info(struct acpi_processor *pr) · line 1121
Quoted 10 lines
drivers/acpi/processor_idle.c +2
-0@@ -1117,6 +1117,8 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr) status =acpi_get_parent (handle, &pr_ahandle);while (ACPI_SUCCESS (status)) { d =acpi_fetch_acpi_dev (pr_ahandle); +if (!d) +break ;But shouldn't this be continue?
I think here is break instead of continue because if we use continue, variable status will not change. Then the while condition will stay true and loop forever.
Quoted 6 lines
Quoted 6 lines
drivers/acpi/processor_idle.c +0
-1handle = pr_ahandle;if (strcmp (acpi_device_hid (d),ACPI_PROCESSOR_CONTAINER_HID )) --2.25.1
Rafael J. Wysocki
maintainerQuoted 14 lines · Li Zhong
The return value of
acpi_fetch_acpi_dev()could be NULL, which will cause null pointer dereference if used inacpi_device_hid().Signed-off-by Li Zhong <[email protected]>--- drivers/acpi/processor_idle.c | 2 ++ 1 file changed, 2 insertions(+)drivers/acpi/processor_idle.c +0
-0
drivers/acpi/processor_idle.c static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
Quoted 9 lines
drivers/acpi/processor_idle.c +2
-1@@ -1117,6 +1117,8 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr) status =acpi_get_parent (handle, &pr_ahandle);while (ACPI_SUCCESS (status)) { d =acpi_fetch_acpi_dev (pr_ahandle); +if (!d) +break ; handle = pr_ahandle;if (strcmp (acpi_device_hid (d),ACPI_PROCESSOR_CONTAINER_HID )) --
Applied (with some edits in the subject and changelog) as 6.1 material, thanks!