diff options
author | Michael Walle <michael@walle.cc> | 2023-02-06 14:43:48 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-06 19:06:59 +0100 |
commit | cc5bdd323dde6494623f3ffe3a5b887fa21cd375 (patch) | |
tree | cb2a19c18bcdf305e529b07a31b55555c8d9bd48 /drivers | |
parent | nvmem: core: move struct nvmem_cell_info to nvmem-provider.h (diff) | |
download | linux-cc5bdd323dde6494623f3ffe3a5b887fa21cd375.tar.xz linux-cc5bdd323dde6494623f3ffe3a5b887fa21cd375.zip |
nvmem: core: drop the removal of the cells in nvmem_add_cells()
If nvmem_add_cells() fails, the whole nvmem_register() will fail
and the cells will then be removed anyway. This is a preparation
to introduce a nvmem_add_one_cell() which can then be used by
nvmem_add_cells().
This is then the same to what nvmem_add_cells_from_table() and
nvmem_add_cells_from_of() do.
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230206134356.839737-15-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/nvmem/core.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 30567dd51fba..98ae70695f36 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -515,7 +515,7 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, int ncells) { struct nvmem_cell_entry **cells; - int i, rval; + int i, rval = 0; cells = kcalloc(ncells, sizeof(*cells), GFP_KERNEL); if (!cells) @@ -525,28 +525,22 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, cells[i] = kzalloc(sizeof(**cells), GFP_KERNEL); if (!cells[i]) { rval = -ENOMEM; - goto err; + goto out; } rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, &info[i], cells[i]); if (rval) { kfree(cells[i]); - goto err; + goto out; } nvmem_cell_entry_add(cells[i]); } +out: /* remove tmp array */ kfree(cells); - return 0; -err: - while (i--) - nvmem_cell_entry_drop(cells[i]); - - kfree(cells); - return rval; } |