diff options
| author | Niklas Cassel <[email protected]> | 2025-01-23 12:01:48 +0000 |
|---|---|---|
| committer | Krzysztof Wilczyński <[email protected]> | 2025-03-08 14:36:06 +0000 |
| commit | 7e80bbef1d697dbce7a39cfad0df770880fe3f29 (patch) | |
| tree | 24e7b3673c602332dd0c650d3498ebb3671de52c /drivers/misc/pci_endpoint_test.c | |
| parent | misc: pci_endpoint_test: Fix potential truncation in pci_endpoint_test_probe() (diff) | |
| download | kernel-7e80bbef1d697dbce7a39cfad0df770880fe3f29.tar.gz kernel-7e80bbef1d697dbce7a39cfad0df770880fe3f29.zip | |
misc: pci_endpoint_test: Give disabled BARs a distinct error code
The current code returns -ENOMEM if test->bar[barno] is NULL.
There can be two reasons why test->bar[barno] is NULL:
1) The pci_ioremap_bar() call in pci_endpoint_test_probe() failed.
2) The BAR was skipped, because it is disabled by the endpoint.
Many PCI endpoint controller drivers will disable all BARs in their
init function. A disabled BAR will have a size of 0.
A PCI endpoint function driver will be able to enable any BAR that
is not marked as BAR_RESERVED (which means that the BAR should not
be touched by the EPF driver).
Thus, perform check if the size is 0, before checking if
test->bar[barno] is NULL, such that we can return different errors.
This will allow the selftests to return SKIP instead of FAIL for
disabled BARs.
Signed-off-by: Niklas Cassel <[email protected]>
Reviewed-by: Manivannan Sadhasivam <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Manivannan Sadhasivam <[email protected]>
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Diffstat (limited to 'drivers/misc/pci_endpoint_test.c')
| -rw-r--r-- | drivers/misc/pci_endpoint_test.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 0fa5ddd1969b..705659f5f0e9 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -292,11 +292,13 @@ static int pci_endpoint_test_bar(struct pci_endpoint_test *test, void *read_buf __free(kfree) = NULL; struct pci_dev *pdev = test->pdev; + bar_size = pci_resource_len(pdev, barno); + if (!bar_size) + return -ENODATA; + if (!test->bar[barno]) return -ENOMEM; - bar_size = pci_resource_len(pdev, barno); - if (barno == test->test_reg_bar) bar_size = 0x4; |
