[PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size

Koichiro Den posted 1 patch 2 weeks ago
drivers/misc/pci_endpoint_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size
Posted by Koichiro Den 2 weeks ago
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@kernel.org>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
 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
Re: [PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size
Posted by Manivannan Sadhasivam 13 hours ago
On Fri, 20 Mar 2026 23:01:39 +0900, Koichiro Den wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] misc: pci_endpoint_test: Use -EINVAL for small subrange size
      commit: 9c55d0eb4e9d1bf229d691363fb0641a9b05d904

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>
Re: [PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size
Posted by Niklas Cassel 2 weeks ago
On Fri, Mar 20, 2026 at 11:01:39PM +0900, Koichiro Den wrote:
> 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@kernel.org>
> Signed-off-by: Koichiro Den <den@valinux.co.jp>

Reviewed-by: Niklas Cassel <cassel@kernel.org>