Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1228438 > unrolled thread
| Started by | Axel Lin <axel.lin@ingics.com> |
|---|---|
| First post | 2015-09-19 15:00 +0200 |
| Last post | 2015-09-19 15:00 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH] nvmem: core: Fix memory leak in nvmem_cell_write Axel Lin <axel.lin@ingics.com> - 2015-09-19 15:00 +0200
| From | Axel Lin <axel.lin@ingics.com> |
|---|---|
| Date | 2015-09-19 15:00 +0200 |
| Subject | [PATCH] nvmem: core: Fix memory leak in nvmem_cell_write |
| Message-ID | <qapUe-1PM-13@gated-at.bofh.it> |
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> --- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index c39723a..bde792d 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)) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to top | Article view | linux.kernel
csiph-web