This is a note to let you know that I've just added the patch titled nvmem: core: fix cell removal on error to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: nvmem-core-fix-cell-removal-on-error.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From db3546d58b5a0fa581d9c9f2bdc2856fa6c5e43e Mon Sep 17 00:00:00 2001 From: Michael Walle <michael@xxxxxxxx> Date: Fri, 27 Jan 2023 10:40:13 +0000 Subject: nvmem: core: fix cell removal on error From: Michael Walle <michael@xxxxxxxx> commit db3546d58b5a0fa581d9c9f2bdc2856fa6c5e43e upstream. 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@xxxxxxxxxxxxxxx Signed-off-by: Michael Walle <michael@xxxxxxxx> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx> Link: https://lore.kernel.org/r/20230127104015.23839-9-srinivas.kandagatla@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/nvmem/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -847,7 +847,7 @@ struct nvmem_device *nvmem_register(cons 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(cons err_remove_cells: nvmem_device_remove_all_cells(nvmem); -err_teardown_compat: if (config->compat) nvmem_sysfs_remove_compat(nvmem, config); err_put_device: Patches currently in stable-queue which might be from michael@xxxxxxxx are queue-6.1/nvmem-core-fix-device-node-refcounting.patch queue-6.1/nvmem-core-fix-cell-removal-on-error.patch