dmaengine: dw-edma: Add pcim_iomap_table return check
Currently, is missing a null check on a pcim_iomap_table() return value and this can lead to a null pointer dereference if the desired BAR wasn't mapped previously. Fix this by adding a null check and returning -ENOMEM. Addresses-Coverity: ("Dereference null return") Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com> Link: https://lore.kernel.org/r/bc5e6b8632c84660bb6dae454980e9419992ed14.1613674948.git.gustavo.pimentel@synopsys.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
Родитель
b671d098a9
Коммит
84b0aa2e0d
|
@ -240,6 +240,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
dw->rd_ch_cnt = vsec_data.rd_ch_cnt;
|
dw->rd_ch_cnt = vsec_data.rd_ch_cnt;
|
||||||
|
|
||||||
dw->rg_region.vaddr = pcim_iomap_table(pdev)[vsec_data.rg.bar];
|
dw->rg_region.vaddr = pcim_iomap_table(pdev)[vsec_data.rg.bar];
|
||||||
|
if (!dw->rg_region.vaddr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
dw->rg_region.vaddr += vsec_data.rg.off;
|
dw->rg_region.vaddr += vsec_data.rg.off;
|
||||||
dw->rg_region.paddr = pdev->resource[vsec_data.rg.bar].start;
|
dw->rg_region.paddr = pdev->resource[vsec_data.rg.bar].start;
|
||||||
dw->rg_region.paddr += vsec_data.rg.off;
|
dw->rg_region.paddr += vsec_data.rg.off;
|
||||||
|
@ -252,12 +255,18 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
struct dw_edma_block *dt_block = &vsec_data.dt_wr[i];
|
struct dw_edma_block *dt_block = &vsec_data.dt_wr[i];
|
||||||
|
|
||||||
ll_region->vaddr = pcim_iomap_table(pdev)[ll_block->bar];
|
ll_region->vaddr = pcim_iomap_table(pdev)[ll_block->bar];
|
||||||
|
if (!ll_region->vaddr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
ll_region->vaddr += ll_block->off;
|
ll_region->vaddr += ll_block->off;
|
||||||
ll_region->paddr = pdev->resource[ll_block->bar].start;
|
ll_region->paddr = pdev->resource[ll_block->bar].start;
|
||||||
ll_region->paddr += ll_block->off;
|
ll_region->paddr += ll_block->off;
|
||||||
ll_region->sz = ll_block->sz;
|
ll_region->sz = ll_block->sz;
|
||||||
|
|
||||||
dt_region->vaddr = pcim_iomap_table(pdev)[dt_block->bar];
|
dt_region->vaddr = pcim_iomap_table(pdev)[dt_block->bar];
|
||||||
|
if (!dt_region->vaddr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
dt_region->vaddr += dt_block->off;
|
dt_region->vaddr += dt_block->off;
|
||||||
dt_region->paddr = pdev->resource[dt_block->bar].start;
|
dt_region->paddr = pdev->resource[dt_block->bar].start;
|
||||||
dt_region->paddr += dt_block->off;
|
dt_region->paddr += dt_block->off;
|
||||||
|
@ -271,12 +280,18 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
struct dw_edma_block *dt_block = &vsec_data.dt_rd[i];
|
struct dw_edma_block *dt_block = &vsec_data.dt_rd[i];
|
||||||
|
|
||||||
ll_region->vaddr = pcim_iomap_table(pdev)[ll_block->bar];
|
ll_region->vaddr = pcim_iomap_table(pdev)[ll_block->bar];
|
||||||
|
if (!ll_region->vaddr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
ll_region->vaddr += ll_block->off;
|
ll_region->vaddr += ll_block->off;
|
||||||
ll_region->paddr = pdev->resource[ll_block->bar].start;
|
ll_region->paddr = pdev->resource[ll_block->bar].start;
|
||||||
ll_region->paddr += ll_block->off;
|
ll_region->paddr += ll_block->off;
|
||||||
ll_region->sz = ll_block->sz;
|
ll_region->sz = ll_block->sz;
|
||||||
|
|
||||||
dt_region->vaddr = pcim_iomap_table(pdev)[dt_block->bar];
|
dt_region->vaddr = pcim_iomap_table(pdev)[dt_block->bar];
|
||||||
|
if (!dt_region->vaddr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
dt_region->vaddr += dt_block->off;
|
dt_region->vaddr += dt_block->off;
|
||||||
dt_region->paddr = pdev->resource[dt_block->bar].start;
|
dt_region->paddr = pdev->resource[dt_block->bar].start;
|
||||||
dt_region->paddr += dt_block->off;
|
dt_region->paddr += dt_block->off;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче