]> git.baikalelectronics.ru Git - kernel.git/commit
mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>
Sat, 3 Apr 2021 06:09:05 +0000 (23:09 -0700)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 7 Apr 2021 08:07:32 +0000 (10:07 +0200)
commit856219ccb8cb9cc79e64dcf02bf17f94f1ad516a
tree23f005e25775899aca57cabfbcca258c9e8f5941
parentcbddc136b12299118791b6ddee4db03ab2f1b846
mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init

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: afd35ff5de629 ("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
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c