Skip to content

Commit

Permalink
tpm: Do not dereference NULL pointer if acpi_os_map_memory() fails.
Browse files Browse the repository at this point in the history
In drivers/char/tpm/tpm_acpi.c::read_log() we call
acpi_os_map_memory(). That call may fail for a number of reasons
(invalid address, out of memory etc). If the call fails it returns
NULL and we just pass that to memcpy() unconditionally, which will go
bad when it tries to dereference the pointer.

Unfortunately we just get NULL back, so we can't really tell the user
exactely what went wrong, but we can at least avoid crashing and
return an error (-EIO seemed more generic and more suitable here than
-ENOMEM or something else, so I picked that).

Signed-off-by: Jesper Juhl <[email protected]>
Signed-off-by: Kent Yoder <[email protected]>
  • Loading branch information
jjuhl authored and Kent Yoder committed Aug 22, 2012
1 parent 20328b5 commit f334ac8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/char/tpm/tpm_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ int read_log(struct tpm_bios_log *log)
log->bios_event_log_end = log->bios_event_log + len;

virt = acpi_os_map_memory(start, len);
if (!virt) {
kfree(log->bios_event_log);
printk("%s: ERROR - Unable to map memory\n", __func__);
return -EIO;
}

memcpy(log->bios_event_log, virt, len);

Expand Down

0 comments on commit f334ac8

Please sign in to comment.