]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: endpoint: pci-epf-vntb: Return -ERANGE for out-of-range MW index
authorKoichiro Den <den@valinux.co.jp>
Thu, 19 Feb 2026 14:56:33 +0000 (23:56 +0900)
committerManivannan Sadhasivam <mani@kernel.org>
Tue, 24 Feb 2026 10:37:56 +0000 (16:07 +0530)
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.

Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20260219145633.4191325-1-den@valinux.co.jp
drivers/pci/endpoint/functions/pci-epf-vntb.c

index 71a35f575cc1de7f0be56211d9a8b50f3bc10785..148a3b160812ec18eb0f4b76f6807f8968e754cc 100644 (file)
@@ -1004,7 +1004,7 @@ static ssize_t epf_ntb_##_name##_show(struct config_item *item,           \
        if (idx < 0 || idx >= ntb->num_mws) {                           \
                dev_err(dev, "MW%d out of range (num_mws=%d)\n",        \
                        win_no, ntb->num_mws);                          \
-               return -EINVAL;                                         \
+               return -ERANGE;                                         \
        }                                                               \
        idx = array_index_nospec(idx, ntb->num_mws);                    \
        return sprintf(page, "%llu\n", ntb->mws_size[idx]);             \
@@ -1032,7 +1032,7 @@ static ssize_t epf_ntb_##_name##_store(struct config_item *item,  \
        if (idx < 0 || idx >= ntb->num_mws) {                           \
                dev_err(dev, "MW%d out of range (num_mws=%d)\n",        \
                        win_no, ntb->num_mws);                          \
-               return -EINVAL;                                         \
+               return -ERANGE;                                         \
        }                                                               \
        idx = array_index_nospec(idx, ntb->num_mws);                    \
        ntb->mws_size[idx] = val;                                       \