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>
Thu, 19 Mar 2020 06:41:03 +0000 (07:41 +0100)
commit3c91ef69a3e94f78546b246225ed573fbf1735b4
tree3251acb10ce8c6a59de3426fa5810b002a730114
parent061a320b32d47438d64d64b412c0ea2c323a1470
nvmem: check for NULL reg_read and reg_write before dereferencing

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
03cd45d2e219 ("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