Skip to content

Commit 1e76f42

Browse files
emuslndavem330
authored andcommitted
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/[email protected]/ Fixes: 523847d ("pds_core: add devcmd device interfaces") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Shannon Nelson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a30449 commit 1e76f42

File tree

1 file changed

+13
-8
lines changed
  • drivers/net/ethernet/amd/pds_core

1 file changed

+13
-8
lines changed

drivers/net/ethernet/amd/pds_core/main.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,16 @@ static int pdsc_init_pf(struct pdsc *pdsc)
244244
set_bit(PDSC_S_FW_DEAD, &pdsc->state);
245245

246246
err = pdsc_setup(pdsc, PDSC_SETUP_INIT);
247-
if (err)
247+
if (err) {
248+
mutex_unlock(&pdsc->config_lock);
248249
goto err_out_unmap_bars;
250+
}
251+
249252
err = pdsc_start(pdsc);
250-
if (err)
253+
if (err) {
254+
mutex_unlock(&pdsc->config_lock);
251255
goto err_out_teardown;
256+
}
252257

253258
mutex_unlock(&pdsc->config_lock);
254259

@@ -257,13 +262,15 @@ static int pdsc_init_pf(struct pdsc *pdsc)
257262
err = devl_params_register(dl, pdsc_dl_params,
258263
ARRAY_SIZE(pdsc_dl_params));
259264
if (err) {
265+
devl_unlock(dl);
260266
dev_warn(pdsc->dev, "Failed to register devlink params: %pe\n",
261267
ERR_PTR(err));
262-
goto err_out_unlock_dl;
268+
goto err_out_stop;
263269
}
264270

265271
hr = devl_health_reporter_create(dl, &pdsc_fw_reporter_ops, 0, pdsc);
266272
if (IS_ERR(hr)) {
273+
devl_unlock(dl);
267274
dev_warn(pdsc->dev, "Failed to create fw reporter: %pe\n", hr);
268275
err = PTR_ERR(hr);
269276
goto err_out_unreg_params;
@@ -279,15 +286,13 @@ static int pdsc_init_pf(struct pdsc *pdsc)
279286
return 0;
280287

281288
err_out_unreg_params:
282-
devl_params_unregister(dl, pdsc_dl_params,
283-
ARRAY_SIZE(pdsc_dl_params));
284-
err_out_unlock_dl:
285-
devl_unlock(dl);
289+
devlink_params_unregister(dl, pdsc_dl_params,
290+
ARRAY_SIZE(pdsc_dl_params));
291+
err_out_stop:
286292
pdsc_stop(pdsc);
287293
err_out_teardown:
288294
pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING);
289295
err_out_unmap_bars:
290-
mutex_unlock(&pdsc->config_lock);
291296
del_timer_sync(&pdsc->wdtimer);
292297
if (pdsc->wq)
293298
destroy_workqueue(pdsc->wq);

0 commit comments

Comments
 (0)