From: Oleg Drokin Date: Mon, 12 May 2025 07:21:13 +0000 (-0400) Subject: LU-19003 ptlrpc: prevent freed memory access in ptlrpcd_init() X-Git-Tag: 2.16.56~58 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=33442e0cab14fd2a7896dc7ace5ff61f1874da6b;p=fs%2Flustre-release.git LU-19003 ptlrpc: prevent freed memory access in ptlrpcd_init() When ptlrpcd_cpts is used, an array is allocated with parsed arguments, and then freed before the last user is done with it. Move freeing to the end of ptlrpcd_init() to fix this. Test-Parameters: trivial Fixes: 2686b25c30 ("LU-6325 ptlrpc: make ptlrpcd threads cpt-aware") Signed-off-by: Oleg Drokin Change-Id: I84847f00ca7df6a9cc56962a09bfe41c1435223e Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59185 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/ptlrpc/ptlrpcd.c b/lustre/ptlrpc/ptlrpcd.c index e09bff1..43297e2 100644 --- a/lustre/ptlrpc/ptlrpcd.c +++ b/lustre/ptlrpc/ptlrpcd.c @@ -742,7 +742,6 @@ static int ptlrpcd_init(void) ptlrpcds_cpt_idx[cpt] = i; } - cfs_expr_list_values_free(cpts, rc); ncpts = rc; } ptlrpcds_num = ncpts; @@ -895,6 +894,8 @@ static int ptlrpcd_init(void) } } out: + if (cpts != NULL) + cfs_expr_list_values_free(cpts, ncpts); if (rc != 0) ptlrpcd_fini();