If uio_register_device() fails in probe(), it breaks off initialization,
deallocates all resources, but returns zero.
The patch adds proper error code propagation.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <[email protected]>
---
drivers/uio/uio_pci_generic.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
index 077ae12269ce..d0b508b68f3c 100644
--- a/drivers/uio/uio_pci_generic.c
+++ b/drivers/uio/uio_pci_generic.c
@@ -91,7 +91,8 @@ static int probe(struct pci_dev *pdev,
gdev->info.handler = irqhandler;
gdev->pdev = pdev;
- if (uio_register_device(&pdev->dev, &gdev->info))
+ err = uio_register_device(&pdev->dev, &gdev->info);
+ if (err)
goto err_register;
pci_set_drvdata(pdev, gdev);
--
1.9.1
On Sat, Dec 06, 2014 at 12:28:01AM +0300, Alexey Khoroshilov wrote:
> If uio_register_device() fails in probe(), it breaks off initialization,
> deallocates all resources, but returns zero.
>
> The patch adds proper error code propagation.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
> ---
> drivers/uio/uio_pci_generic.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
> index 077ae12269ce..d0b508b68f3c 100644
> --- a/drivers/uio/uio_pci_generic.c
> +++ b/drivers/uio/uio_pci_generic.c
> @@ -91,7 +91,8 @@ static int probe(struct pci_dev *pdev,
> gdev->info.handler = irqhandler;
> gdev->pdev = pdev;
>
> - if (uio_register_device(&pdev->dev, &gdev->info))
> + err = uio_register_device(&pdev->dev, &gdev->info);
> + if (err)
> goto err_register;
> pci_set_drvdata(pdev, gdev);
>
> --
> 1.9.1