The layout is being retrieved before the addition of nvmem cells and after the creation of the sysfs entries. Soon the layout operation will have the possibility to fail, hence adding a new goto label in the error path. Before doing so, we need to fix the operation order in the error path. Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> --- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 56b4b20a95a9..16044377a41d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -975,9 +975,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) err_remove_cells: nvmem_device_remove_all_cells(nvmem); + nvmem_layout_put(nvmem->layout); if (config->compat) nvmem_sysfs_remove_compat(nvmem, config); - nvmem_layout_put(nvmem->layout); err_put_device: put_device(&nvmem->dev); -- 2.34.1