From: Akhil Goyal <gak...@marvell.com> Fixed resource leak when pthread create fails in dev_init().
Fixes: 1c7a4d37e73d ("common/cnxk: fix mailbox timeout due to deadlock") Signed-off-by: Akhil Goyal <gak...@marvell.com> --- drivers/common/cnxk/roc_dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index 128b9751e4..18d7981825 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -1472,7 +1472,7 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev) pf_vf_mbox_thread_main, dev); if (rc != 0) { plt_err("Failed to create thread for VF mbox handling\n"); - goto iounmap; + goto thread_fail; } } @@ -1500,9 +1500,10 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev) dev->sync.start_thread = false; pthread_cond_signal(&dev->sync.pfvf_msg_cond); pthread_join(dev->sync.pfvf_msg_thread, NULL); - pthread_mutex_destroy(&dev->sync.mutex); - pthread_cond_destroy(&dev->sync.pfvf_msg_cond); } +thread_fail: + pthread_mutex_destroy(&dev->sync.mutex); + pthread_cond_destroy(&dev->sync.pfvf_msg_cond); iounmap: dev_vf_mbase_put(pci_dev, vf_mbase); mbox_unregister: -- 2.25.1