summaryrefslogtreecommitdiffstats
path: root/drivers/nvmem
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2020-03-10 14:22:51 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-03-19 07:41:03 +0100
commit061a320b32d47438d64d64b412c0ea2c323a1470 (patch)
tree4b5238045c623eb9b6d634687e1bdc0c973a6d6c /drivers/nvmem
parentnvmem: release the write-protect pin (diff)
downloadlinux-061a320b32d47438d64d64b412c0ea2c323a1470.tar.xz
linux-061a320b32d47438d64d64b412c0ea2c323a1470.zip
nvmem: core: validate nvmem config before parsing
nvmem provider has to provide either reg_read/write, add a check to enforce this. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20200310132257.23358-9-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r--drivers/nvmem/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index c05c4f4a7b9e..77d890d3623d 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -339,6 +339,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
if (!config->dev)
return ERR_PTR(-EINVAL);
+ if (!config->reg_read && !config->reg_write)
+ return ERR_PTR(-EINVAL);
+
nvmem = kzalloc(sizeof(*nvmem), GFP_KERNEL);
if (!nvmem)
return ERR_PTR(-ENOMEM);