Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1329569
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] nvmem: core: fix error path in nvmem_add_cells() |
| Date | 2016-02-08 22:10 +0100 |
| Message-ID | <r01eh-2kE-13@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
The current code fails to nvmem_cell_drop(cells[0]) - even worse, if the loop above fails already at i==0, we'll enter an essentially infinite loop doing nvmem_cell_drop on cells[-1], cells[-2], ... which is unlikely to end well. Also, we're not freeing the temporary backing array cells on the error path. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> --- drivers/nvmem/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 6fd4e5a5ef4a..1e65eccfea83 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -288,9 +288,11 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, return 0; err: - while (--i) + while (i--) nvmem_cell_drop(cells[i]); + kfree(cells); + return rval; } -- 2.1.4
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] nvmem: core: fix error path in nvmem_add_cells() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-08 22:10 +0100
Re: [PATCH] nvmem: core: fix error path in nvmem_add_cells() Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2016-02-17 11:50 +0100
Re: [PATCH] nvmem: core: fix error path in nvmem_add_cells() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-18 06:40 +0100
Re: [PATCH] nvmem: core: fix error path in nvmem_add_cells() Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2016-02-18 10:10 +0100
csiph-web