drivers/tty/moxa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Add pci_disable_device() into the error handling, and therefore make the
function not jump to err if pci_enable_device() failed.
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
---
drivers/tty/moxa.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index f3c72ab1476c..4432a39331d3 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -1239,7 +1239,7 @@ static int moxa_pci_probe(struct pci_dev *pdev,
retval = pci_enable_device(pdev);
if (retval) {
dev_err(&pdev->dev, "can't enable pci device\n");
- goto err;
+ return retval;
}
for (i = 0; i < MAX_BOARDS; i++)
@@ -1300,6 +1300,7 @@ static int moxa_pci_probe(struct pci_dev *pdev,
err_reg:
pci_release_region(pdev, 2);
err:
+ pci_disable_device(pdev);
return retval;
}
--
2.25.1
On Mon, Aug 01, 2022 at 04:53:56PM +0800, GONG, Ruiqi wrote:
> Add pci_disable_device() into the error handling, and therefore make the
> function not jump to err if pci_enable_device() failed.
>
> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
> ---
> drivers/tty/moxa.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
> index f3c72ab1476c..4432a39331d3 100644
> --- a/drivers/tty/moxa.c
> +++ b/drivers/tty/moxa.c
> @@ -1239,7 +1239,7 @@ static int moxa_pci_probe(struct pci_dev *pdev,
> retval = pci_enable_device(pdev);
> if (retval) {
> dev_err(&pdev->dev, "can't enable pci device\n");
> - goto err;
> + return retval;
> }
>
> for (i = 0; i < MAX_BOARDS; i++)
> @@ -1300,6 +1300,7 @@ static int moxa_pci_probe(struct pci_dev *pdev,
> err_reg:
> pci_release_region(pdev, 2);
> err:
> + pci_disable_device(pdev);
Are you sure you want to do this? What happens if this is a
multi-function device, you just turned it off, right?
How did you test this change? Do you have the hardware for it?
thanks,
greg k-h
© 2016 - 2026 Red Hat, Inc.