summaryrefslogtreecommitdiff
path: root/drivers/pci
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2022-03-22 17:16:23 -0500
committerBjorn Helgaas <bhelgaas@google.com>2022-03-22 17:16:23 -0500
commita69e89ba6c810295b4ce795ce38088788857822f (patch)
treeddc98a49b384d4a77e8c83133b295dc5a8a8bfcc /drivers/pci
parent0321da851e3ed1a61619f822f94d66e96f463c05 (diff)
parentbf8d87c076f55b8b4dfdb6bc6c6b6dc0c2ccb487 (diff)
Merge branch 'remotes/lorenzo/pci/endpoint'
- Fix alignment fault error in copy tests (Hou Zhiqiang) - Fix misused goto label (Li Chen) * remotes/lorenzo/pci/endpoint: PCI: endpoint: Fix misused goto label PCI: endpoint: Fix alignment fault error in copy tests
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/endpoint/functions/pci-epf-test.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 90d84d3bc868..5b833f00e980 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -285,7 +285,17 @@ static int pci_epf_test_copy(struct pci_epf_test *epf_test)
if (ret)
dev_err(dev, "Data transfer failed\n");
} else {
- memcpy(dst_addr, src_addr, reg->size);
+ void *buf;
+
+ buf = kzalloc(reg->size, GFP_KERNEL);
+ if (!buf) {
+ ret = -ENOMEM;
+ goto err_map_addr;
+ }
+
+ memcpy_fromio(buf, src_addr, reg->size);
+ memcpy_toio(dst_addr, buf, reg->size);
+ kfree(buf);
}
ktime_get_ts64(&end);
pci_epf_test_print_rate("COPY", reg->size, &start, &end, use_dma);
@@ -441,7 +451,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test)
if (!epf_test->dma_supported) {
dev_err(dev, "Cannot transfer data using DMA\n");
ret = -EINVAL;
- goto err_map_addr;
+ goto err_dma_map;
}
src_phys_addr = dma_map_single(dma_dev, buf, reg->size,