ACPI/nfit: avoid accessing uninitialized memory in acpi_nfit_ctl()
Subsystems (2)
PATCH 1/1 ACPI/nfit: avoid accessing uninitialized memory in acpi_nfit_ctl()
The ACPI_ALLOCATE() does not zero the "buf", so when the condition "integer->type != ACPI_TYPE_INTEGER" in int_to_buf() is met, the result is unpredictable in acpi_nfit_ctl().
Signed-off-by Zhen Lei <[email protected]>
--- drivers/acpi/nfit/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/acpi/nfit/core.c +5 -4
@@ -282,18 +282,19 @@ static union acpi_object *pkg_to_buf(union acpi_object *pkg)static union acpi_object *int_to_buf (union acpi_object *integer) { -union acpi_object *buf =ACPI_ALLOCATE (sizeof (*buf) +4 ); +union acpi_object *buf =NULL ;void *dst =NULL ; -if (!buf) - goto err; -if (integer->type !=ACPI_TYPE_INTEGER ) {WARN_ONCE (1 ,"BIOS bug, unexpected element type: %d\n" , integer->type); goto err; } + buf =ACPI_ALLOCATE (sizeof (*buf) +4 ); +if (!buf) + goto err; + dst = buf +1 ; buf->type =ACPI_TYPE_BUFFER ; buf->buffer.length =4 ;
Signature · 5 lines
2.26.0.106.g9fadedd _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Quoted 6 lines · Zhen Lei
The
ACPI_ALLOCATE()does not zero the "buf", so when the condition "integer->type!=ACPI_TYPE_INTEGER" inint_to_buf()is met, the result is unpredictable inacpi_nfit_ctl().Signed-off-by Zhen Lei <[email protected]>
Looks good to me.
Reviewed-by Dan Williams <[email protected]>
I'll pick this up.