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: [email protected] Signed-off-by: Michael Walle <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent edcf2fb commit db3546d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

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)