gpu: add null check for mali session memtrack [1/1]
authorJiyu Yang <Jiyu.Yang@amlogic.com>
Thu, 21 Sep 2017 10:06:33 +0000 (18:06 +0800)
committerJiyu Yang <jiyu.yang@amlogic.com>
Sat, 30 Sep 2017 06:15:35 +0000 (23:15 -0700)
use default value if null

Change-Id: Ia725afb83c9fa33a3a8c3e9e487273aeeb245f7c

mali/common/mali_session.c
utgard/r5p1/common/mali_session.c
utgard/r6p1/common/mali_session.c
utgard/r6p2/common/mali_session.c
utgard/r7p0/common/mali_session.c [changed mode: 0644->0755]

index 692cea502553c849d891610830ad53119ce525ab..95819f6635c9309ac78af7dd5161a593cfc23eb5 100755 (executable)
@@ -114,6 +114,7 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 {
        struct mali_session_data *session, *tmp;
        char task_comm[TASK_COMM_LEN];
+       char task_default[] = "not found";
        struct task_struct *ttask;
        u32 mali_mem_usage;
        u32 total_mali_mem_size;
@@ -127,7 +128,10 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 
        MALI_SESSION_FOREACH(session, tmp, link) {
                ttask = pid_task(find_vpid(session->pid), PIDTYPE_PID);
-               strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               if (ttask)
+                       strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               else
+                       strncpy(task_comm, task_default, sizeof(task_default));
 #ifdef MALI_MEM_SWAP_TRACKING
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u %-25s %-10u  %-15u  %-15u  %-10u  %-10u %-10u\n",
                                    session->comm, session->pid, task_comm,
index 6506b1d22861190945fec580aed2539bd2985d7e..5c06c3e172be0ebf0ae22985eec4909049683b48 100755 (executable)
@@ -92,6 +92,7 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 {
        struct mali_session_data *session, *tmp;
        char task_comm[TASK_COMM_LEN];
+       char task_default[] = "not found";
        struct task_struct *ttask;
        u32 mali_mem_usage;
        u32 total_mali_mem_size;
@@ -102,7 +103,10 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
        MALI_SESSION_FOREACH(session, tmp, link) {
                ttask = pid_task(find_vpid(session->pid), PIDTYPE_PID);
                //get_task_comm(task_comm, ttask);
-               strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               if (ttask)
+                       strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               else
+                       strncpy(task_comm, task_default, sizeof(task_default));
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u %-25s %-10u  %-15u  %-15u  %-10u  %-10u\n",
                                    session->comm, session->pid,  task_comm,
                                    session->mali_mem_array[MALI_MEM_OS] + session->mali_mem_array[MALI_MEM_BLOCK], session->max_mali_mem_allocated,
index ec42dee853ca9817bce83659913cd914c639d88d..9c5a64a15461f847d9fedb294dbb8cbbfff6704b 100755 (executable)
@@ -103,6 +103,7 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 {
        struct mali_session_data *session, *tmp;
        char task_comm[TASK_COMM_LEN];
+       char task_default[] = "not found";
        struct task_struct *ttask;
        u32 mali_mem_usage;
        u32 total_mali_mem_size;
@@ -116,7 +117,10 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 
        MALI_SESSION_FOREACH(session, tmp, link) {
                ttask = pid_task(find_vpid(session->pid), PIDTYPE_PID);
-               strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               if (ttask)
+                       strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               else
+                       strncpy(task_comm, task_default, sizeof(task_default));
 #ifdef MALI_MEM_SWAP_TRACKING
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u %-25s %-10u  %-15u  %-15u  %-10u  %-10u %-10u\n",
                                    session->comm, session->pid, task_comm,
index ec42dee853ca9817bce83659913cd914c639d88d..9c5a64a15461f847d9fedb294dbb8cbbfff6704b 100755 (executable)
@@ -103,6 +103,7 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 {
        struct mali_session_data *session, *tmp;
        char task_comm[TASK_COMM_LEN];
+       char task_default[] = "not found";
        struct task_struct *ttask;
        u32 mali_mem_usage;
        u32 total_mali_mem_size;
@@ -116,7 +117,10 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 
        MALI_SESSION_FOREACH(session, tmp, link) {
                ttask = pid_task(find_vpid(session->pid), PIDTYPE_PID);
-               strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               if (ttask)
+                       strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               else
+                       strncpy(task_comm, task_default, sizeof(task_default));
 #ifdef MALI_MEM_SWAP_TRACKING
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u %-25s %-10u  %-15u  %-15u  %-10u  %-10u %-10u\n",
                                    session->comm, session->pid, task_comm,
old mode 100644 (file)
new mode 100755 (executable)
index 138598d..11e4cf4
@@ -115,6 +115,7 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 {
        struct mali_session_data *session, *tmp;
        char task_comm[TASK_COMM_LEN];
+       char task_default[] = "not found";
        struct task_struct *ttask;
        u32 mali_mem_usage;
        u32 total_mali_mem_size;
@@ -128,7 +129,10 @@ void mali_session_memory_tracking(_mali_osk_print_ctx *print_ctx)
 
        MALI_SESSION_FOREACH(session, tmp, link) {
                ttask = pid_task(find_vpid(session->pid), PIDTYPE_PID);
-               strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               if (ttask)
+                       strncpy(task_comm, ttask->comm, sizeof(ttask->comm));
+               else
+                       strncpy(task_comm, task_default, sizeof(task_default));
 #ifdef MALI_MEM_SWAP_TRACKING
                _mali_osk_ctxprintf(print_ctx, "  %-25s  %-10u %-25s %-10u  %-15u  %-15u  %-10u  %-10u %-10u\n",
                                    session->comm, session->pid, task_comm,