Skip to content

Commit 3c91c90

Browse files
AlexiousLuPaolo Abeni
authored andcommitted
octeontx2-af: fix a use-after-free in rvu_npa_register_reporters
The rvu_dl will be freed in rvu_npa_health_reporters_destroy(rvu_dl) after the create_workqueue fails, and after that free, the rvu_dl will be translate back through rvu_npa_health_reporters_create, rvu_health_reporters_create, and rvu_register_dl. Finally it goes to the err_dl_health label, being freed again in rvu_health_reporters_destroy(rvu) by rvu_npa_health_reporters_destroy. In the second calls of rvu_npa_health_reporters_destroy, however, it uses rvu_dl->rvu_npa_health_reporter, which is already freed at the end of rvu_npa_health_reporters_destroy in the first call. So this patch prevents the first destroy by instantly returning -ENONMEN when create_workqueue fails. In addition, since the failure of create_workqueue is the only entrence of label err, it has been integrated into the error-handling path of create_workqueue. Fixes: f1168d1 ("octeontx2-af: Add devlink health reporters for NPA") Signed-off-by: Zhipeng Lu <[email protected]> Acked-by: Paolo Abeni <[email protected]> Acked-by: Geethasowjanya Akula <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 37e4b8d commit 3c91c90

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,17 +1087,14 @@ static int rvu_npa_register_reporters(struct rvu_devlink *rvu_dl)
10871087

10881088
rvu_dl->devlink_wq = create_workqueue("rvu_devlink_wq");
10891089
if (!rvu_dl->devlink_wq)
1090-
goto err;
1090+
return -ENOMEM;
10911091

10921092
INIT_WORK(&rvu_reporters->intr_work, rvu_npa_intr_work);
10931093
INIT_WORK(&rvu_reporters->err_work, rvu_npa_err_work);
10941094
INIT_WORK(&rvu_reporters->gen_work, rvu_npa_gen_work);
10951095
INIT_WORK(&rvu_reporters->ras_work, rvu_npa_ras_work);
10961096

10971097
return 0;
1098-
err:
1099-
rvu_npa_health_reporters_destroy(rvu_dl);
1100-
return -ENOMEM;
11011098
}
11021099

11031100
static int rvu_npa_health_reporters_create(struct rvu_devlink *rvu_dl)

0 commit comments

Comments
 (0)