diff mbox series

[v3,4.19.y-cip,15/17] spi: spi-mem: Fix a memory leak in spi_mem_dirmap_destroy()

Message ID 20210105135757.11069-16-prabhakar.mahadev-lad.rj@bp.renesas.com (mailing list archive)
State Accepted
Headers show
Series Add Renesas RPC-IF driver | expand

Commit Message

Lad Prabhakar Jan. 5, 2021, 1:57 p.m. UTC
From: Boris Brezillon <bbrezillon@kernel.org>

commit bfecfd6e23bf677c85828eb20fa4b13a18bffe23 upstream.

The dirmap descriptor object allocated in spi_mem_dirmap_create is
never freed. Add a kfree(desc) in spi_mem_dirmap_destroy().

Fixes: aa167f3fed0c ("spi: spi-mem: Add a new API to support direct mapping")
Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/spi/spi-mem.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 0998ebc2689d..c3a08afb6edf 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -542,6 +542,8 @@  void spi_mem_dirmap_destroy(struct spi_mem_dirmap_desc *desc)
 
 	if (!desc->nodirmap && ctlr->mem_ops && ctlr->mem_ops->dirmap_destroy)
 		ctlr->mem_ops->dirmap_destroy(desc);
+
+	kfree(desc);
 }
 EXPORT_SYMBOL_GPL(spi_mem_dirmap_destroy);