aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2015-09-30 08:36:10 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-04 07:09:43 -0400
commitace22170655f61d82fff95e57d673bf847a32a03 (patch)
tree5a4543e05214b84bedc1d52ac14db14c67a5d559
parentcbf854ab36870b931aeba4edd954015b7c3005a2 (diff)
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>
-rw-r--r--drivers/nvmem/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 676607cb01bb..6fd4e5a5ef4a 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -938,7 +938,7 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
938 rc = regmap_raw_write(nvmem->regmap, cell->offset, buf, cell->bytes); 938 rc = regmap_raw_write(nvmem->regmap, cell->offset, buf, cell->bytes);
939 939
940 /* free the tmp buffer */ 940 /* free the tmp buffer */
941 if (cell->bit_offset) 941 if (cell->bit_offset || cell->nbits)
942 kfree(buf); 942 kfree(buf);
943 943
944 if (IS_ERR_VALUE(rc)) 944 if (IS_ERR_VALUE(rc))