MLK-23000-1 mxc: mlb: fix kernel dump when use gen_pool_dma_alloc

If use dma pool when iram does not exist, the iram_pool will be NULL.
The previous version of lib/genalloc.c will check the pointer status
first. In 5.4, it will not check NULL pointer.
Therefore, add NULL check here.

Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
This commit is contained in:
Clark Wang 2019-11-19 12:26:10 +08:00 committed by Dong Aisheng
parent f086607708
commit d229e2c9b5
1 changed files with 4 additions and 1 deletions

View File

@ -1971,7 +1971,10 @@ static int mxc_mlb150_open(struct inode *inode, struct file *filp)
ring_buf_size = pdevinfo->buf_size;
buf_size = ring_buf_size * (TRANS_RING_NODES * 2);
buf_addr = gen_pool_dma_alloc(drvdata->iram_pool, buf_size, &phy_addr);
if (drvdata->iram_pool)
buf_addr = gen_pool_dma_alloc(drvdata->iram_pool, buf_size, &phy_addr);
else
buf_addr = NULL;
if (!buf_addr) {
drvdata->use_iram = false;
buf_addr = dma_alloc_coherent(drvdata->dev, buf_size, &phy_addr, GFP_KERNEL);