Skip to content

Commit 28a7cb0

Browse files
AlexiousLudavem330
authored andcommitted
octeontx2-af: fix a use-after-free in rvu_nix_register_reporters
The rvu_dl will be freed in rvu_nix_health_reporters_destroy(rvu_dl) after the create_workqueue fails, and after that free, the rvu_dl will be translate back through the following call chain: rvu_nix_health_reporters_destroy |-> rvu_nix_health_reporters_create |-> rvu_health_reporters_create |-> rvu_register_dl (label err_dl_health) Finally. in the err_dl_health label, rvu_dl being freed again in rvu_health_reporters_destroy(rvu) by rvu_nix_health_reporters_destroy. In the second calls of rvu_nix_health_reporters_destroy, however, it uses rvu_dl->rvu_nix_health_reporter, which is already freed at the end of rvu_nix_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: 5ed6630 ("octeontx2-af: Add devlink health reporters for NIX") Signed-off-by: Zhipeng Lu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9fc95fe commit 28a7cb0

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
@@ -538,17 +538,14 @@ static int rvu_nix_register_reporters(struct rvu_devlink *rvu_dl)
538538

539539
rvu_dl->devlink_wq = create_workqueue("rvu_devlink_wq");
540540
if (!rvu_dl->devlink_wq)
541-
goto err;
541+
return -ENOMEM;
542542

543543
INIT_WORK(&rvu_reporters->intr_work, rvu_nix_intr_work);
544544
INIT_WORK(&rvu_reporters->gen_work, rvu_nix_gen_work);
545545
INIT_WORK(&rvu_reporters->err_work, rvu_nix_err_work);
546546
INIT_WORK(&rvu_reporters->ras_work, rvu_nix_ras_work);
547547

548548
return 0;
549-
err:
550-
rvu_nix_health_reporters_destroy(rvu_dl);
551-
return -ENOMEM;
552549
}
553550

554551
static int rvu_nix_health_reporters_create(struct rvu_devlink *rvu_dl)

0 commit comments

Comments
 (0)