提交 10b0be52 编写于 作者: L Lv Yunlong 提交者: Zheng Zengkai

mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init

stable inclusion
from stable-5.10.37
commit b1d1f644ed9e2fb9e2b3e6bee413e45e74ee022d
bugzilla: 51868
CVE: NA

--------------------------------

[ Upstream commit 076de75d ]

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: 4d02423e ("mtd: nand: gpmi: Fix gpmi_nand_init() error path")
Signed-off-by: NLv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210403060905.5251-1-lyl2019@mail.ustc.edu.cnSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 daca1346
...@@ -2447,7 +2447,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) ...@@ -2447,7 +2447,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
this->bch_geometry.auxiliary_size = 128; this->bch_geometry.auxiliary_size = 128;
ret = gpmi_alloc_dma_buffer(this); ret = gpmi_alloc_dma_buffer(this);
if (ret) if (ret)
goto err_out; return ret;
nand_controller_init(&this->base); nand_controller_init(&this->base);
this->base.ops = &gpmi_nand_controller_ops; this->base.ops = &gpmi_nand_controller_ops;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册