Skip to content

Commit 1ad82f9

Browse files
Dan Carpenterbjorn-helgaas
authored andcommitted
misc: pci_endpoint_test: Fix array underflow in pci_endpoint_test_ioctl()
Commit eefb837 ("misc: pci_endpoint_test: Add doorbell test case") added NO_BAR (-1) to the pci_barno enum which, in practical terms, changes the enum from an unsigned int to a signed int. If the user passes a negative number in pci_endpoint_test_ioctl() then it results in an array underflow in pci_endpoint_test_bar(). Fixes: eefb837 ("misc: pci_endpoint_test: Add doorbell test case") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/aIzzZ4vc6ZrmM9rI@suswa
1 parent 57a75fa commit 1ad82f9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/misc/pci_endpoint_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
937937
switch (cmd) {
938938
case PCITEST_BAR:
939939
bar = arg;
940-
if (bar > BAR_5)
940+
if (bar <= NO_BAR || bar > BAR_5)
941941
goto ret;
942942
if (is_am654_pci_dev(pdev) && bar == BAR_0)
943943
goto ret;

0 commit comments

Comments
 (0)