public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size
@ 2026-03-20 14:01 Koichiro Den
  2026-03-20 14:03 ` Niklas Cassel
  0 siblings, 1 reply; 2+ messages in thread
From: Koichiro Den @ 2026-03-20 14:01 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Niklas Cassel, Christian Bruel,
	Arnd Bergmann, Greg Kroah-Hartman
  Cc: linux-pci, linux-kernel

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size
  2026-03-20 14:01 [PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size Koichiro Den
@ 2026-03-20 14:03 ` Niklas Cassel
  0 siblings, 0 replies; 2+ messages in thread
From: Niklas Cassel @ 2026-03-20 14:03 UTC (permalink / raw)
  To: Koichiro Den
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Christian Bruel, Arnd Bergmann,
	Greg Kroah-Hartman, linux-pci, linux-kernel

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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-20 14:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 14:01 [PATCH] misc: pci_endpoint_test: Use -EINVAL for small subrange size Koichiro Den
2026-03-20 14:03 ` Niklas Cassel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox