提交 dfdf1414 编写于 作者: R Rasmus Villemoes 提交者: Greg Kroah-Hartman

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.
Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 990162f0
......@@ -294,9 +294,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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册