aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Grosjean <s.grosjean@peak-system.com>2017-11-23 09:44:35 -0500
committerMarc Kleine-Budde <mkl@pengutronix.de>2017-12-01 05:20:52 -0500
commit5c2cb02edf79ad79d9b8d07c6d52243a948c4c9f (patch)
tree9bf6eba1d991a9e003e7dc9c9bc9faa97850c8e0
parentf6c23b174c3c96616514827407769cbcfc8005cf (diff)
can: peak/pci: fix potential bug when probe() fails
PCI/PCIe drivers for PEAK-System CAN/CAN-FD interfaces do some access to the PCI config during probing. In case one of these accesses fails, a POSITIVE PCIBIOS_xxx error code is returned back. This POSITIVE error code MUST be converted into a NEGATIVE errno for the probe() function to indicate it failed. Using the pcibios_err_to_errno() function, we make sure that the return code will always be negative. Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--drivers/net/can/peak_canfd/peak_pciefd_main.c5
-rw-r--r--drivers/net/can/sja1000/peak_pci.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c
index b4efd711f824..788c3464a3b0 100644
--- a/drivers/net/can/peak_canfd/peak_pciefd_main.c
+++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c
@@ -825,7 +825,10 @@ err_release_regions:
825err_disable_pci: 825err_disable_pci:
826 pci_disable_device(pdev); 826 pci_disable_device(pdev);
827 827
828 return err; 828 /* pci_xxx_config_word() return positive PCIBIOS_xxx error codes while
829 * the probe() function must return a negative errno in case of failure
830 * (err is unchanged if negative) */
831 return pcibios_err_to_errno(err);
829} 832}
830 833
831/* free the board structure object, as well as its resources: */ 834/* free the board structure object, as well as its resources: */
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
index 131026fbc2d7..5adc95c922ee 100644
--- a/drivers/net/can/sja1000/peak_pci.c
+++ b/drivers/net/can/sja1000/peak_pci.c
@@ -717,7 +717,10 @@ failure_release_regions:
717failure_disable_pci: 717failure_disable_pci:
718 pci_disable_device(pdev); 718 pci_disable_device(pdev);
719 719
720 return err; 720 /* pci_xxx_config_word() return positive PCIBIOS_xxx error codes while
721 * the probe() function must return a negative errno in case of failure
722 * (err is unchanged if negative) */
723 return pcibios_err_to_errno(err);
721} 724}
722 725
723static void peak_pci_remove(struct pci_dev *pdev) 726static void peak_pci_remove(struct pci_dev *pdev)