mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-15 22:31:47 -04:00
nvmem: core: Fix memory leak in nvmem_cell_write
A tmp buffer is allocated if cell->bit_offset || cell->nbits. So the tmp buffer needs to be freed at the same condition to avoid leak. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cbf854ab36
commit
ace2217065
@@ -938,7 +938,7 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
|
||||
rc = regmap_raw_write(nvmem->regmap, cell->offset, buf, cell->bytes);
|
||||
|
||||
/* free the tmp buffer */
|
||||
if (cell->bit_offset)
|
||||
if (cell->bit_offset || cell->nbits)
|
||||
kfree(buf);
|
||||
|
||||
if (IS_ERR_VALUE(rc))
|
||||
|
||||
Reference in New Issue
Block a user