Skip to contentSkip to conversation

PCI: endpoint: Fix a NULL vs IS_ERR() check in pci_epf_test_init_dma_chan()

PATCH In review Peng Wu 2 participants 2 messages Jul 7, 2022 – Jul 11, 2022

Subsystems (2)
lore
Share & tools
lore

Peng Wu

author
#0 lore raw

PATCH 1/1 PCI: endpoint: Fix a NULL vs IS_ERR() check in pci_epf_test_init_dma_chan()

On failure, dma_request_channel() returns NULL and not a ERR_PTR() value. Fix return value checking by using is NULL.

---
 drivers/pci/endpoint/functions/pci-epf-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-test.c +1 -1
index 34aac220dd4c..eed6638ab71d 100644
@@ -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.17.1
#1 lore raw

[+cc Dan, Shunsuke]

Quoted 4 lines · Peng Wu

On failure, dma_request_channel() returns NULL and not a ERR_PTR() value. Fix return value checking by using is NULL.

Thanks for the patch. Dan posted the same thing later [1].

I'd be happy to do this, but Shunsuke suggested that the rx path should be changed similarly, so I'll look for a patch that does both.

[1] https://lore.kernel.org/r/YsftwaVowtU9/pgn@kili
[2] https://lore.kernel.org/r/CANXvt5rK98-cEMgpzopY9POOK8a5=VDib8uKPLgJakOG=hRfwQ@mail.gmail.com

Quoted 20 lines
---
 drivers/pci/endpoint/functions/pci-epf-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-test.c +1 -1
index 34aac220dd4c..eed6638ab71d 100644
@@ -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.17.1