From: Axel Lin Date: Wed, 30 Sep 2015 12:36:10 +0000 (+0100) Subject: nvmem: core: Fix memory leak in nvmem_cell_write X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ace22170655f61d82fff95e57d673bf847a32a03;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Srinivas Kandagatla Signed-off-by: Greg Kroah-Hartman --- 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) 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))