2017-09-06 13:51:04

by Zhenhua

[permalink] [raw]
Subject: [PATCH 1/1] ACPI: NULL pointer checking

These two pointers should be checked, for some broken devices they may
cause system crash.

Signed-off-by: Zhenhua <[email protected]>
---
drivers/acpi/acpica/nsaccess.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index f2733f51ca8d..151abb0ef4d5 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -338,7 +338,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
return_ACPI_STATUS(AE_AML_INTERNAL);
}

- if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) {
+ if ((!prefix_node) && (!(flags & ACPI_NS_PREFIX_IS_SCOPE))) {
/*
* This node might not be a actual "scope" node (such as a
* Device/Method, etc.) It could be a Package or other object
@@ -369,7 +369,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
"Null Pathname (Zero segments), Flags=%X\n",
flags));
- } else {
+ } else if (path) {
/*
* Name pointer is valid (and must be in internal name format)
*
--
2.14.1



2017-09-06 16:42:45

by Moore, Robert

[permalink] [raw]
Subject: RE: [PATCH 1/1] ACPI: NULL pointer checking



> -----Original Message-----
> From: Zhenhua [mailto:[email protected]]
> Sent: Wednesday, September 6, 2017 6:35 AM
> To: [email protected]; Moore, Robert <[email protected]>; Zheng, Lv
> <[email protected]>; Wysocki, Rafael J <[email protected]>;
> [email protected]; [email protected]; linux-
> [email protected]
> Cc: Zhenhua <[email protected]>
> Subject: [PATCH 1/1] ACPI: NULL pointer checking
>
> These two pointers should be checked, for some broken devices they may
> cause system crash.
>
> Signed-off-by: Zhenhua <[email protected]>
> ---
> drivers/acpi/acpica/nsaccess.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/acpica/nsaccess.c
> b/drivers/acpi/acpica/nsaccess.c index f2733f51ca8d..151abb0ef4d5 100644
> --- a/drivers/acpi/acpica/nsaccess.c
> +++ b/drivers/acpi/acpica/nsaccess.c
> @@ -338,7 +338,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
> return_ACPI_STATUS(AE_AML_INTERNAL);
> }
>
> - if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) {
> + if ((!prefix_node) && (!(flags & ACPI_NS_PREFIX_IS_SCOPE))) {
[Moore, Robert]

Is there an actual case where the original code failed?



> /*
> * This node might not be a actual "scope" node (such as
> a
> * Device/Method, etc.) It could be a Package or other
> object @@ -369,7 +369,7 @@ acpi_ns_lookup(union acpi_generic_state
> *scope_info,
> ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
> "Null Pathname (Zero segments), Flags=%X\n",
> flags));
> - } else {
> + } else if (path) {
> /*
> * Name pointer is valid (and must be in internal name
> format)
> *
> --
> 2.14.1
>

2017-09-07 19:27:00

by Moore, Robert

[permalink] [raw]
Subject: RE: [PATCH 1/1] ACPI: NULL pointer checking



> -----Original Message-----
> From: Devel [mailto:[email protected]] On Behalf Of Moore, Robert
> Sent: Wednesday, September 6, 2017 9:43 AM
> To: Zhenhua <[email protected]>; [email protected]; Zheng, Lv
> <[email protected]>; Wysocki, Rafael J <[email protected]>;
> [email protected]; [email protected]; linux-
> [email protected]
> Subject: Re: [Devel] [PATCH 1/1] ACPI: NULL pointer checking
>
>
>
> > -----Original Message-----
> > From: Zhenhua [mailto:[email protected]]
> > Sent: Wednesday, September 6, 2017 6:35 AM
> > To: [email protected]; Moore, Robert <[email protected]>; Zheng,
> > Lv <[email protected]>; Wysocki, Rafael J
> > <[email protected]>; [email protected];
> > [email protected]; linux- [email protected]
> > Cc: Zhenhua <[email protected]>
> > Subject: [PATCH 1/1] ACPI: NULL pointer checking
> >
> > These two pointers should be checked, for some broken devices they may
> > cause system crash.
> >
> > Signed-off-by: Zhenhua <[email protected]>
> > ---
> > drivers/acpi/acpica/nsaccess.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/acpi/acpica/nsaccess.c
> > b/drivers/acpi/acpica/nsaccess.c index f2733f51ca8d..151abb0ef4d5
> > 100644
> > --- a/drivers/acpi/acpica/nsaccess.c
> > +++ b/drivers/acpi/acpica/nsaccess.c
> > @@ -338,7 +338,7 @@ acpi_ns_lookup(union acpi_generic_state
> *scope_info,
> > return_ACPI_STATUS(AE_AML_INTERNAL);
> > }
> >
> > - if (!(flags & ACPI_NS_PREFIX_IS_SCOPE)) {
> > + if ((!prefix_node) && (!(flags & ACPI_NS_PREFIX_IS_SCOPE))) {
> [Moore, Robert]
>
> Is there an actual case where the original code failed?
>
>
[Moore, Robert]

Prefix_node is guaranteed to be valid at this point in the code.


>
> > /*
> > * This node might not be a actual "scope" node (such as
> a
> > * Device/Method, etc.) It could be a Package or other
> object @@
> > -369,7 +369,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
> > ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
> > "Null Pathname (Zero segments), Flags=%X\n",
> > flags));
> > - } else {
> > + } else if (path) {
[Moore, Robert]

Likewise, "path" is guaranteed to be valid at this point.


> > /*
> > * Name pointer is valid (and must be in internal name
> > format)
> > *
> > --
> > 2.14.1
> >
>
> _______________________________________________
> Devel mailing list
> [email protected]
> https://lists.acpica.org/mailman/listinfo/devel