Whamcloud - gitweb
LU-19003 ptlrpc: prevent freed memory access in ptlrpcd_init() 85/59185/3
authorOleg Drokin <green@whamcloud.com>
Mon, 12 May 2025 07:21:13 +0000 (03:21 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 21 May 2025 05:19:16 +0000 (05:19 +0000)
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 <green@whamcloud.com>
Change-Id: I84847f00ca7df6a9cc56962a09bfe41c1435223e
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59185
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/ptlrpc/ptlrpcd.c

index e09bff1..43297e2 100644 (file)
@@ -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();