From: Mr. NeilBrown Date: Thu, 13 Aug 2020 12:44:25 +0000 (-0400) Subject: LU-9859 libcfs: discard TCD_MAX_TYPES X-Git-Tag: 2.14.51~121 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=bf7f08479fa28fc4c1a0513d4eb75f91c7577227 LU-9859 libcfs: discard TCD_MAX_TYPES As well as CFS_TCD_TYPE_CNT we have TCD_MAX_TYPES which has a larger value but a similar meaning. Discard it and just use CFS_TCD_TYPE_CNT. Two places relied on the fact that TCD_MAX_TYPES was larger and so there would be NULLs at the end of the array. Change them to check the array size properly. Linux-commit: 22627ffa5e7fae0b0b62f90a8f30fc6dae0fff3c Change-Id: I73a54a409674d3b569bcbaf72e2296209542b74c Signed-off-by: Mr. NeilBrown Reviewed-on: https://review.whamcloud.com/39668 Reviewed-by: Jian Yu Reviewed-by: Yang Sheng Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index f026ec1..eb89132 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -49,7 +49,6 @@ #include #define CFS_TRACE_CONSOLE_BUFFER_SIZE 1024 -#define TCD_MAX_TYPES 8 enum cfs_trace_buf_type { CFS_TCD_TYPE_PROC = 0, @@ -58,7 +57,7 @@ enum cfs_trace_buf_type { CFS_TCD_TYPE_CNT }; -union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline_aligned; +union cfs_trace_data_union (*cfs_trace_data[CFS_TCD_TYPE_CNT])[NR_CPUS] __cacheline_aligned; char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_CNT]; char cfs_tracefile[TRACEFILE_NAME_SIZE]; @@ -109,13 +108,13 @@ void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking) } #define cfs_tcd_for_each(tcd, i, j) \ - for (i = 0; cfs_trace_data[i]; i++) \ + for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i]; i++) \ for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd); \ j < num_possible_cpus(); \ j++, (tcd) = &(*cfs_trace_data[i])[j].tcd) #define cfs_tcd_for_each_type_lock(tcd, i, cpu) \ - for (i = 0; cfs_trace_data[i] && \ + for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i] && \ (tcd = &(*cfs_trace_data[i])[cpu].tcd) && \ cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++) @@ -1326,7 +1325,7 @@ static void cfs_trace_cleanup(void) cfs_trace_console_buffers[i][j] = NULL; } - for (i = 0; cfs_trace_data[i]; i++) { + for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i]; i++) { kfree(cfs_trace_data[i]); cfs_trace_data[i] = NULL; }