mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 04:29:11 -04:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a9c3766cb1
commit
061a320b32
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user