spi: spi-mem: Fix a memory leak in spi_mem_dirmap_destroy()
authorBoris Brezillon <bbrezillon@kernel.org>
Sat, 19 Jan 2019 14:57:57 +0000 (15:57 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 21 Jan 2019 17:57:14 +0000 (17:57 +0000)
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>
drivers/spi/spi-mem.c

index 08ba43506e81a622171eadee5c8f6f4dfde3f9ad..9487c9cd68bdee4a083c9561b07851d762df11c5 100644 (file)
@@ -547,6 +547,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);