PCI: endpoint: IS_ERR() vs NULL bug in pci_epf_test_init_dma_chan()
Subsystems (3)
PATCH v2 1/1 PCI: endpoint: IS_ERR() vs NULL bug in pci_epf_test_init_dma_chan()
The dma_request_channel() function doesn't return error pointers, it returns NULL.
Fixes fff86dfbbf82 ("PCI: endpoint: Enable DMA tests for endpoints with DMA capabilities")
Signed-off-by Dan Carpenter <[email protected]>
---
v2: Clean up the first IS_ERR_OR_NULL() check as well
drivers/pci/endpoint/functions/pci-epf-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/endpoint/functions/pci-epf-test.c +2 -2
@@ -211,7 +211,7 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test)dma_cap_zero (mask);dma_cap_set (DMA_SLAVE , mask); dma_chan =dma_request_channel (mask, epf_dma_filter_fn, &filter); -if (IS_ERR_OR_NULL (dma_chan)) { +if (!dma_chan) {dev_info (dev,"Failed to get private DMA rx channel. Falling back to generic one\n" ); goto fail_back_tx; }
@@ -221,7 +221,7 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test) filter.dma_mask =BIT (DMA_MEM_TO_DEV ); dma_chan =dma_request_channel (mask, epf_dma_filter_fn, &filter); -if (IS_ERR (dma_chan)) { +if (!dma_chan) {dev_info (dev,"Failed to get private DMA tx channel. Falling back to generic one\n" ); goto fail_back_rx; }
Signature · 1 line
2.35.1
Quoted 5 lines · Dan Carpenter
The
dma_request_channel()function doesn't return error pointers, it returns NULL.Fixes fff86dfbbf82 ("PCI: endpoint: Enable DMA tests for endpoints with DMA capabilities")Signed-off-by Dan Carpenter <[email protected]>
Thanks, I squashed this into fff86dfbbf82 on my pci/ctrl/dwc-edma branch. I added a mention of Shunsuke's previous post of a similar fix, but merged this one because it fixes both the RX and TX paths.
Quoted 31 lines
---
v2: Clean up the firstIS_ERR_OR_NULL()check as welldrivers/pci/endpoint/functions/pci-epf-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/endpoint/functions/pci-epf-test.c +2
-2@@ -211,7 +211,7 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test)dma_cap_zero (mask);dma_cap_set (DMA_SLAVE , mask); dma_chan =dma_request_channel (mask, epf_dma_filter_fn, &filter); -if (IS_ERR_OR_NULL (dma_chan)) { +if (!dma_chan) {dev_info (dev,"Failed to get private DMA rx channel. Falling back to generic one\n" ); goto fail_back_tx; }@@ -221,7 +221,7 @@ static int pci_epf_test_init_dma_chan(struct pci_epf_test *epf_test) filter.dma_mask =BIT (DMA_MEM_TO_DEV ); dma_chan =dma_request_channel (mask, epf_dma_filter_fn, &filter); -if (IS_ERR (dma_chan)) { +if (!dma_chan) {dev_info (dev,"Failed to get private DMA tx channel. Falling back to generic one\n" ); goto fail_back_rx; }Signature · 1 line
2.35.1