Commit 1e76f427 authored by Shannon Nelson's avatar Shannon Nelson Committed by David S. Miller

pds_core: fix mutex double unlock in error path

Fix a double unlock in an error handling path by unlocking as soon as
the error is seen and removing unlocks in the error cleanup path.

Link: https://lore.kernel.org/kernel-janitors/209a09f6-5ec6-40c7-a5ec-6260d8f54d25@kili.mountain/
Fixes: 523847df ("pds_core: add devcmd device interfaces")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarShannon Nelson <shannon.nelson@amd.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1a304495
...@@ -244,11 +244,16 @@ static int pdsc_init_pf(struct pdsc *pdsc) ...@@ -244,11 +244,16 @@ static int pdsc_init_pf(struct pdsc *pdsc)
set_bit(PDSC_S_FW_DEAD, &pdsc->state); set_bit(PDSC_S_FW_DEAD, &pdsc->state);
err = pdsc_setup(pdsc, PDSC_SETUP_INIT); err = pdsc_setup(pdsc, PDSC_SETUP_INIT);
if (err) if (err) {
mutex_unlock(&pdsc->config_lock);
goto err_out_unmap_bars; goto err_out_unmap_bars;
}
err = pdsc_start(pdsc); err = pdsc_start(pdsc);
if (err) if (err) {
mutex_unlock(&pdsc->config_lock);
goto err_out_teardown; goto err_out_teardown;
}
mutex_unlock(&pdsc->config_lock); mutex_unlock(&pdsc->config_lock);
...@@ -257,13 +262,15 @@ static int pdsc_init_pf(struct pdsc *pdsc) ...@@ -257,13 +262,15 @@ static int pdsc_init_pf(struct pdsc *pdsc)
err = devl_params_register(dl, pdsc_dl_params, err = devl_params_register(dl, pdsc_dl_params,
ARRAY_SIZE(pdsc_dl_params)); ARRAY_SIZE(pdsc_dl_params));
if (err) { if (err) {
devl_unlock(dl);
dev_warn(pdsc->dev, "Failed to register devlink params: %pe\n", dev_warn(pdsc->dev, "Failed to register devlink params: %pe\n",
ERR_PTR(err)); ERR_PTR(err));
goto err_out_unlock_dl; goto err_out_stop;
} }
hr = devl_health_reporter_create(dl, &pdsc_fw_reporter_ops, 0, pdsc); hr = devl_health_reporter_create(dl, &pdsc_fw_reporter_ops, 0, pdsc);
if (IS_ERR(hr)) { if (IS_ERR(hr)) {
devl_unlock(dl);
dev_warn(pdsc->dev, "Failed to create fw reporter: %pe\n", hr); dev_warn(pdsc->dev, "Failed to create fw reporter: %pe\n", hr);
err = PTR_ERR(hr); err = PTR_ERR(hr);
goto err_out_unreg_params; goto err_out_unreg_params;
...@@ -279,15 +286,13 @@ static int pdsc_init_pf(struct pdsc *pdsc) ...@@ -279,15 +286,13 @@ static int pdsc_init_pf(struct pdsc *pdsc)
return 0; return 0;
err_out_unreg_params: err_out_unreg_params:
devl_params_unregister(dl, pdsc_dl_params, devlink_params_unregister(dl, pdsc_dl_params,
ARRAY_SIZE(pdsc_dl_params)); ARRAY_SIZE(pdsc_dl_params));
err_out_unlock_dl: err_out_stop:
devl_unlock(dl);
pdsc_stop(pdsc); pdsc_stop(pdsc);
err_out_teardown: err_out_teardown:
pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING); pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING);
err_out_unmap_bars: err_out_unmap_bars:
mutex_unlock(&pdsc->config_lock);
del_timer_sync(&pdsc->wdtimer); del_timer_sync(&pdsc->wdtimer);
if (pdsc->wq) if (pdsc->wq)
destroy_workqueue(pdsc->wq); destroy_workqueue(pdsc->wq);
......
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