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

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.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a9c3766c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);