UPSTREAM: nvmem: core: fix error path in nvmem_add_cells()
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Mon, 8 Feb 2016 21:04:29 +0000 (22:04 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 5 Aug 2016 03:04:40 +0000 (11:04 +0800)
commit3a22addaefc7d50305dd0a7f07e03f6fa9b5cca6
tree9e2ee27da2afb40a4b00b93a9639e343f8bc46c0
parentce59a0c64ed5e97bfdbf799b0e8d922ccb4fd261
UPSTREAM: nvmem: core: fix error path in nvmem_add_cells()

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.

Change-Id: I1029a520e86f2c2fd2ad9054037c86b129dde172
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
(cherry pick from dfdf141429f0895b63c882facc42c86f225033cb)
drivers/nvmem/core.c