Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: pci_endpoint_test: fix return value of error branch

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>

authored by

Xiongfeng Wang and committed by
Greg Kroah-Hartman
1749c904 505b0877

+6 -2
+6 -2
drivers/misc/pci_endpoint_test.c
··· 811 811 812 812 pci_set_master(pdev); 813 813 814 - if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type)) 814 + if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type)) { 815 + err = -EINVAL; 815 816 goto err_disable_irq; 817 + } 816 818 817 819 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { 818 820 if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { ··· 851 849 goto err_ida_remove; 852 850 } 853 851 854 - if (!pci_endpoint_test_request_irq(test)) 852 + if (!pci_endpoint_test_request_irq(test)) { 853 + err = -EINVAL; 855 854 goto err_kfree_test_name; 855 + } 856 856 857 857 misc_device = &test->miscdev; 858 858 misc_device->minor = MISC_DYNAMIC_MINOR;