From 1bc46a01aafdb9e3f43ba25e895821023ec5dbd4 Mon Sep 17 00:00:00 2001 From: Vigneshwaran Saravanan/Vigneshwaran Saravanan Date: Tue, 30 Jul 2024 19:15:52 +0530 Subject: [PATCH] plugins/ocp: fix UAF when printing telemetry log Take care the below failures for "telemetry-string-log". Resolved the Segmentation Fault issue while printing. Signed-off-by: Vigneshwaran Saravanan/Vigneshwaran Saravanan Reviewed-by: Karthik Balan Reviewed-by: Arunpandian J --- plugins/ocp/ocp-nvme.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index b6394212..91f4083b 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -902,6 +902,7 @@ static int eol_plp_failure_mode(int argc, char **argv, struct command *cmd, /// Telemetry Log //global buffers static __le64 total_log_page_sz; +static __u8 *header_data; static struct telemetry_str_log_format *log_data; __u8 *ptelemetry_buffer; @@ -1588,8 +1589,6 @@ exit_status: static int get_c9_log_page_data(struct nvme_dev *dev, int print_data, int save_bin) { int ret = 0, fd; - __u8 *header_data; - struct telemetry_str_log_format *log_data; __le64 stat_id_str_table_ofst = 0; __le64 event_str_table_ofst = 0; __le64 vu_event_str_table_ofst = 0; @@ -1663,7 +1662,6 @@ static int get_c9_log_page_data(struct nvme_dev *dev, int print_data, int save_b } exit_status: - free(header_data); return 0; } @@ -3621,7 +3619,7 @@ static int get_c9_log_page(struct nvme_dev *dev, char *format) } } else fprintf(stderr, "ERROR : OCP : Unable to read C9 data from buffer\n"); - + free(header_data); return ret; } -- 2.50.1