Commit 6960af6d authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by John W. Linville

p54pci: don't return zero on failure paths in p54p_probe()

If pci_set_dma_mask() or pci_set_consistent_dma_mask() fails in p54p_probe(),
it breaks off initialization, deallocates all resources, but returns zero.
Similar issue is if check for returned value of pci_resource_len() fails.

The patch implements proper error code propagation.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: default avatarChristian Lamparter <chunkeey@googlemail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 40a23296
...@@ -559,6 +559,7 @@ static int p54p_probe(struct pci_dev *pdev, ...@@ -559,6 +559,7 @@ static int p54p_probe(struct pci_dev *pdev,
mem_len = pci_resource_len(pdev, 0); mem_len = pci_resource_len(pdev, 0);
if (mem_len < sizeof(struct p54p_csr)) { if (mem_len < sizeof(struct p54p_csr)) {
dev_err(&pdev->dev, "Too short PCI resources\n"); dev_err(&pdev->dev, "Too short PCI resources\n");
err = -ENODEV;
goto err_disable_dev; goto err_disable_dev;
} }
...@@ -568,8 +569,10 @@ static int p54p_probe(struct pci_dev *pdev, ...@@ -568,8 +569,10 @@ static int p54p_probe(struct pci_dev *pdev,
goto err_disable_dev; goto err_disable_dev;
} }
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) || err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { if (!err)
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev, "No suitable DMA available\n"); dev_err(&pdev->dev, "No suitable DMA available\n");
goto err_free_reg; goto err_free_reg;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment