From c7a160ec0b0ccfa4c55b0abaf5905302cb98246b Mon Sep 17 00:00:00 2001 From: Manoj Prabhu B Date: Tue, 2 Jul 2019 20:09:55 +0530 Subject: [PATCH] diag: Prevent using uninitialized mdlog session mask Add check to prevent using uninitialized session mask to translate kernel to user mask. Change-Id: I341f0308775a2c5a00856fe6ec8acf9b63e207d9 Signed-off-by: Manoj Prabhu B --- drivers/char/diag/diagchar_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c index b085328517dec..cb23bb704a7ed 100644 --- a/drivers/char/diag/diagchar_core.c +++ b/drivers/char/diag/diagchar_core.c @@ -449,7 +449,7 @@ void diag_clear_masks(int pid) static void diag_close_logging_process(const int pid) { int i, j; - int session_mask; + int session_mask = 0; int device_mask = 0; uint32_t p_mask; struct diag_md_session_t *session_info = NULL; @@ -473,8 +473,9 @@ static void diag_close_logging_process(const int pid) diag_clear_masks(pid); mutex_lock(&driver->diagchar_mutex); - p_mask = - diag_translate_kernel_to_user_mask(session_mask); + if (session_mask) + p_mask = + diag_translate_kernel_to_user_mask(session_mask); for (i = 0; i < NUM_MD_SESSIONS; i++) if (MD_PERIPHERAL_MASK(i) & session_mask)