[PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size
From: Koichiro Den
Date: Fri Mar 20 2026 - 10:07:19 EST
The sub_size check ensures that each subrange is large enough for 32-bit
accesses. Subranges smaller than sizeof(u32) do not satisfy this
assumption, so this is a local sanity check rather than a resource
exhaustion case.
Return -EINVAL instead of -ENOSPC for this case.
Suggested-by: Niklas Cassel <cassel@xxxxxxxxxx>
Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
---
drivers/misc/pci_endpoint_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 55e128ed82f0..496c8f509590 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -543,15 +543,15 @@ static int pci_endpoint_test_bar_subrange(struct pci_endpoint_test *test,
if (bar_size % nsub || bar_size / nsub > SIZE_MAX) {
ret = -EINVAL;
goto out_clear;
}
sub_size = bar_size / nsub;
if (sub_size < sizeof(u32)) {
- ret = -ENOSPC;
+ ret = -EINVAL;
goto out_clear;
}
/* Limit the temporary buffer size */
buf_size = min_t(size_t, sub_size, SZ_1M);
read_buf = kmalloc(buf_size, GFP_KERNEL);
--
2.51.0