Skip to content

Commit

Permalink
nvmem: core: validate nvmem config before parsing
Browse files Browse the repository at this point in the history
nvmem provider has to provide either reg_read/write, add a check
to enforce this.

Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Srinivas-Kandagatla authored and gregkh committed Mar 19, 2020
1 parent a9c3766 commit 061a320
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/nvmem/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 061a320

Please sign in to comment.