From: Pablo de Lara Date: Wed, 21 Jun 2017 06:28:24 +0000 (+0100) Subject: cryptodev: release device if PCI probing fails X-Git-Tag: spdx-start~2947 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d0b316ad6d4aca661f650128f7a0b4631a27129c;p=dpdk.git cryptodev: release device if PCI probing fails Call rte_cryptodev_pmd_release_device() if probing a PCI crypto device, instead of accessing the variables directly. This will be useful when rte_cryptodev_pci_probe() gets moved to a separate file. Signed-off-by: Pablo de Lara Acked-by: Declan Doherty --- diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index c0cfe94e4f..d02a4d0ad9 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -541,9 +541,12 @@ rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev) if (cryptodev == NULL) return -EINVAL; - ret = rte_cryptodev_close(cryptodev->data->dev_id); - if (ret < 0) - return ret; + /* Close device only if device operations have been set */ + if (cryptodev->dev_ops) { + ret = rte_cryptodev_close(cryptodev->data->dev_id); + if (ret < 0) + return ret; + } cryptodev->attached = RTE_CRYPTODEV_DETACHED; cryptodev_globals.nb_devs--; @@ -604,8 +607,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv, if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_free(cryptodev->data->dev_private); - cryptodev->attached = RTE_CRYPTODEV_DETACHED; - cryptodev_globals.nb_devs--; + /* free crypto device */ + rte_cryptodev_pmd_release_device(cryptodev); return -ENXIO; }