Commit 061a320b authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by Greg Kroah-Hartman

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: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20200310132257.23358-9-srinivas.kandagatla@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a9c3766c
...@@ -339,6 +339,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) ...@@ -339,6 +339,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
if (!config->dev) if (!config->dev)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if (!config->reg_read && !config->reg_write)
return ERR_PTR(-EINVAL);
nvmem = kzalloc(sizeof(*nvmem), GFP_KERNEL); nvmem = kzalloc(sizeof(*nvmem), GFP_KERNEL);
if (!nvmem) if (!nvmem)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment