Message ID | 20220426083635.112852-1-zhangqilong3@huawei.com |
---|---|
State | New |
Headers | show |
Series | spi: sh-msiof: Fix potential NULL dereference in sh_msiof_request_dma | expand |
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index d0012b30410c..9d2754cc72b4 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c @@ -1191,6 +1191,9 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p) if (!res) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENOENT; + ctlr = p->ctlr; ctlr->dma_tx = sh_msiof_request_dma_chan(dev, DMA_MEM_TO_DEV, dma_tx_id, res->start + SITFDR);
platform_get_resource() may return NULL, add proper check to avoid potential NULL dereferencing. Fixes: b0d0ce8b6b91a ("spi: sh-msiof: Add DMA support") Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com> --- drivers/spi/spi-sh-msiof.c | 3 +++ 1 file changed, 3 insertions(+)