diff options
author | Michael Walle <michael@walle.cc> | 2023-01-27 10:40:13 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-01-28 14:38:49 +0100 |
commit | db3546d58b5a0fa581d9c9f2bdc2856fa6c5e43e (patch) | |
tree | d964f41332bd51e7f207dafef479b2a79f500684 /drivers/nvmem/core.c | |
parent | edcf2fb660526b5ed29f93bd17328a2b4835c8b2 (diff) | |
download | lwn-db3546d58b5a0fa581d9c9f2bdc2856fa6c5e43e.tar.gz lwn-db3546d58b5a0fa581d9c9f2bdc2856fa6c5e43e.zip |
nvmem: core: fix cell removal on error
nvmem_add_cells() could return an error after some cells are already
added to the provider. In this case, the added cells are not removed.
Remove any registered cells if nvmem_add_cells() fails.
Fixes: fa72d847d68d7 ("nvmem: check the return value of nvmem_add_cells()")
Cc: stable@vger.kernel.org
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230127104015.23839-9-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem/core.c')
-rw-r--r-- | drivers/nvmem/core.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index cbe5df99db82..563116405b3d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -847,7 +847,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (config->cells) { rval = nvmem_add_cells(nvmem, config->cells, config->ncells); if (rval) - goto err_teardown_compat; + goto err_remove_cells; } rval = nvmem_add_cells_from_table(nvmem); @@ -870,7 +870,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) err_remove_cells: nvmem_device_remove_all_cells(nvmem); -err_teardown_compat: if (config->compat) nvmem_sysfs_remove_compat(nvmem, config); err_put_device: |