]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
misc: pci_endpoint_test: fix return value of error branch
authorXiongfeng Wang <wangxiongfeng2@huawei.com>
Thu, 19 Nov 2020 12:49:18 +0000 (20:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Dec 2020 18:43:44 +0000 (19:43 +0100)
We return 'err' in the error branch, but this variable may be set as
zero before. Fix it by setting 'err' as a negative value before we
goto the error label.

Fixes: e03327122e2c ("pci_endpoint_test: Add 2 ioctl commands")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Link: https://lore.kernel.org/r/1605790158-6780-1-git-send-email-wangxiongfeng2@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/pci_endpoint_test.c

index ea9c2c0852989d07d0613acc8b99558d94032df6..eff481ce08ee0e0bcce635419d52a7579f396cb5 100644 (file)
@@ -811,8 +811,10 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
 
        pci_set_master(pdev);
 
-       if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type))
+       if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type)) {
+               err = -EINVAL;
                goto err_disable_irq;
+       }
 
        for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
                if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
@@ -849,8 +851,10 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
                goto err_ida_remove;
        }
 
-       if (!pci_endpoint_test_request_irq(test))
+       if (!pci_endpoint_test_request_irq(test)) {
+               err = -EINVAL;
                goto err_kfree_test_name;
+       }
 
        misc_device = &test->miscdev;
        misc_device->minor = MISC_DYNAMIC_MINOR;