]> git.baikalelectronics.ru Git - kernel.git/commit
nvmem: check for NULL reg_read and reg_write before dereferencing
authorNicholas Johnson <nicholas.johnson-opensource@outlook.com.au>
Tue, 10 Mar 2020 13:22:52 +0000 (13:22 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Apr 2020 07:08:42 +0000 (09:08 +0200)
commit6056f0e5a5ab11a122de66875c274985145d58a2
tree0417273fb4fb89e3c0eabf3abb1e2400f7cc6094
parentaff813c7c0a390fbf338f18f616ac288113defdf
nvmem: check for NULL reg_read and reg_write before dereferencing

commit 9b1e3cd9bb37d901669fd5d1c800f4b9ca9fc2fb upstream.

Return -EPERM if reg_read is NULL in bin_attr_nvmem_read() or if
reg_write is NULL in bin_attr_nvmem_write().

This prevents NULL dereferences such as the one described in
9b4a47e44704 ("thunderbolt: Prevent crash if non-active NVMem file is
read")

Signed-off-by: Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20200310132257.23358-10-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/nvmem-sysfs.c