Skip to content

Commit db3546d

Browse files
mwallegregkh
authored andcommitted
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: fa72d84 ("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>
1 parent edcf2fb commit db3546d

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/nvmem/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
847847
if (config->cells) {
848848
rval = nvmem_add_cells(nvmem, config->cells, config->ncells);
849849
if (rval)
850-
goto err_teardown_compat;
850+
goto err_remove_cells;
851851
}
852852

853853
rval = nvmem_add_cells_from_table(nvmem);
@@ -870,7 +870,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
870870

871871
err_remove_cells:
872872
nvmem_device_remove_all_cells(nvmem);
873-
err_teardown_compat:
874873
if (config->compat)
875874
nvmem_sysfs_remove_compat(nvmem, config);
876875
err_put_device:

0 commit comments

Comments
 (0)