[PATCH] PCI: endpoint: pci-epf-vntb: Return -ERANGE for out-of-range MW index

Koichiro Den posted 1 patch 1 month, 1 week ago
drivers/pci/endpoint/functions/pci-epf-vntb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] PCI: endpoint: pci-epf-vntb: Return -ERANGE for out-of-range MW index
Posted by Koichiro Den 1 month, 1 week ago
The mw1..mw4 configfs attributes are only valid when the MW index is
within the configured num_mws range. Return -ERANGE instead of -EINVAL
when a configfs MW size attribute is accessed with an out-of-range MW
index.

Link: https://lore.kernel.org/linux-pci/n7griejk7mlutc5mdi6b3ysedn2dgcius43urhxnfohjeo32fc@d5gymxxhrutw/
Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index 20a400e83439..3d0fa98109b1 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -1002,7 +1002,7 @@ static ssize_t epf_ntb_##_name##_show(struct config_item *item,		\
 									\
 	if (win_no <= 0 || win_no > ntb->num_mws) {			\
 		dev_err(dev, "Invalid num_nws: %d value\n", ntb->num_mws); \
-		return -EINVAL;						\
+		return -ERANGE;						\
 	}								\
 									\
 	return sprintf(page, "%lld\n", ntb->mws_size[win_no - 1]);	\
@@ -1028,7 +1028,7 @@ static ssize_t epf_ntb_##_name##_store(struct config_item *item,	\
 									\
 	if (win_no <= 0 || win_no > ntb->num_mws) {			\
 		dev_err(dev, "Invalid num_nws: %d value\n", ntb->num_mws); \
-		return -EINVAL;						\
+		return -ERANGE;						\
 	}								\
 									\
 	ntb->mws_size[win_no - 1] = val;				\
-- 
2.51.0
Re: [PATCH] PCI: endpoint: pci-epf-vntb: Return -ERANGE for out-of-range MW index
Posted by Manivannan Sadhasivam 1 month, 1 week ago
On Thu, 19 Feb 2026 23:56:33 +0900, Koichiro Den wrote:
> The mw1..mw4 configfs attributes are only valid when the MW index is
> within the configured num_mws range. Return -ERANGE instead of -EINVAL
> when a configfs MW size attribute is accessed with an out-of-range MW
> index.
> 
> 

Applied, thanks!

[1/1] PCI: endpoint: pci-epf-vntb: Return -ERANGE for out-of-range MW index
      commit: 8eaff52fc101c1f6b3215db93bba02c815155806

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>