diff mbox

ACPI: check zero length in acpi_rs_get_aml_length

Message ID 1358334928-9736-1-git-send-email-jslaby@suse.cz (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Jiri Slaby Jan. 16, 2013, 11:15 a.m. UTC
There is a bug somewhere in the code that does not set the resource
length. This makes the loop in acpi_rs_get_aml_length to loop forever.
So it is a good thing to have the check even if the bug is fixed.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/acpi/acpica/rscalc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Rafael Wysocki Jan. 16, 2013, 1:49 p.m. UTC | #1
Hi,

On Wednesday, January 16, 2013 12:15:28 PM Jiri Slaby wrote:
> There is a bug somewhere in the code that does not set the resource
> length. This makes the loop in acpi_rs_get_aml_length to loop forever.
> So it is a good thing to have the check even if the bug is fixed.

This needs to go through ACPICA upstream (Bob CCed).

> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
>  drivers/acpi/acpica/rscalc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
> index da178b4..c128f2e 100644
> --- a/drivers/acpi/acpica/rscalc.c
> +++ b/drivers/acpi/acpica/rscalc.c
> @@ -198,7 +198,8 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
>  
>  		/* Validate the descriptor type */
>  
> -		if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
> +		if (resource->type > ACPI_RESOURCE_TYPE_MAX ||
> +				WARN_ON(!resource->length)) {

So this cannot be a WARN_ON().

>  			return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
>  		}
>  

Thanks,
Rafael
diff mbox

Patch

diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index da178b4..c128f2e 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -198,7 +198,8 @@  acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
 
 		/* Validate the descriptor type */
 
-		if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
+		if (resource->type > ACPI_RESOURCE_TYPE_MAX ||
+				WARN_ON(!resource->length)) {
 			return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
 		}