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:
Родитель
a9c3766cb1
Коммит
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче