framework/task_manager: Fix memory leak possibility and dereferencing in task_manager_set_callback
WID:8164247 Pointer '&request_msg.data->cb_data' is dereferenced at task_manager_set_callback.c:190 after
the referenced memory was deallocated at task_manager_set_callback.c:189 by calling function 'free'.
@@ -185,14 +185,16 @@ int task_manager_set_broadcast_cb(int msg, void (*func)(void *user_data, void *d
TM_ASPRINTF(&request_msg.q_name, "%s%d", TM_PRIVATE_MQ, request_msg.caller_pid);
if (request_msg.q_name == NULL) {
- TM_FREE(request_msg.data);
+ TM_FREE(((tm_msg_t *)((tm_broadcast_info_t *)request_msg.data)->cb_data)->msg);
TM_FREE(((tm_broadcast_info_t *)request_msg.data)->cb_data);
+ TM_FREE(request_msg.data);
return TM_OUT_OF_MEMORY;
}
status = taskmgr_send_request(&request_msg);
if (status < 0) {
- TM_FREE(request_msg.data);
+ TM_FREE(((tm_msg_t *)((tm_broadcast_info_t *)request_msg.data)->cb_data)->msg);
TM_FREE(((tm_broadcast_info_t *)request_msg.data)->cb_data);
+ TM_FREE(request_msg.data);
if (request_msg.q_name != NULL) {
TM_FREE(request_msg.q_name);
}
