]> git.baikalelectronics.ru Git - kernel.git/commit
tpm: Do not dereference NULL pointer if acpi_os_map_memory() fails.
authorJesper Juhl <jj@chaosbits.net>
Wed, 15 Aug 2012 22:16:33 +0000 (00:16 +0200)
committerKent Yoder <key@linux.vnet.ibm.com>
Wed, 22 Aug 2012 21:23:34 +0000 (16:23 -0500)
commit366557fdc6a4812d0ab9db74aed2975e726a82cb
tree4db3665c9b277abc8e41961345518a24bff60790
parent476a17b5d0eb4d5ca1ebcd4cb89b91621297733b
tpm: Do not dereference NULL pointer if acpi_os_map_memory() fails.

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 <jj@chaosbits.net>
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
drivers/char/tpm/tpm_acpi.c