linux/drivers/mtd/nand
Lv Yunlong ef8e7bfea9 mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init
[ Upstream commit 076de75de1e53160e9b099f75872c1f9adf41a0b ]

If the callee gpmi_alloc_dma_buffer() failed to alloc memory for
this->raw_buffer, gpmi_free_dma_buffer() will be called to free
this->auxiliary_virt. But this->auxiliary_virt is still a non-NULL
and valid ptr.

Then gpmi_alloc_dma_buffer() returns err and gpmi_free_dma_buffer()
is called again to free this->auxiliary_virt in err_out. This causes
a double free.

As gpmi_free_dma_buffer() has already called in gpmi_alloc_dma_buffer's
error path, so it should return err directly instead of releasing the dma
buffer again.

Fixes: 4d02423e9a ("mtd: nand: gpmi: Fix gpmi_nand_init() error path")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210403060905.5251-1-lyl2019@mail.ustc.edu.cn
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-14 09:44:20 +02:00
..
onenand mtd: onenand_base: Adjust indentation in onenand_read_ops_nolock 2020-02-14 16:34:18 -05:00
raw mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init 2021-05-14 09:44:20 +02:00
spi mtd: spinand: core: add missing MODULE_DEVICE_TABLE() 2021-05-11 14:04:02 +02:00
Kconfig
Makefile
bbt.c
core.c