Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ace22170 authored by Axel Lin's avatar Axel Lin Committed by Greg Kroah-Hartman
Browse files

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: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cbf854ab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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))