kmsg: Use TASK_COMM_LEN size buffer for get_task_comm() 77/220277/1
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 17 Dec 2019 01:18:03 +0000 (10:18 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 17 Dec 2019 01:21:45 +0000 (10:21 +0900)
To avoid gcc-8 warning, get_task_comm() is fixed to check size of
buffer from the mainline commit 3756f6401c30 ("exec: avoid gcc-8
warning for get_task_comm"). To apply the commit, use
TASK_COMM_LEN size buffer for get_task_comm() in set_kmsg_dict().

Afte the mainline commit is applied, newly added unnecessary copy
will be removed properly.

Change-Id: Ic9a55c667143d5311e1e01c4ec9b44c7f2148eae
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
kernel/printk_kmsg.c

index 00515b82561fb8a54b271b7b8e3749004266a371..ff1dedbcd3b3c8816e3fb880bdd2de0b2b6fb757 100644 (file)
@@ -874,12 +874,14 @@ void log_buf_release(struct kref *ref)
 static size_t set_kmsg_dict(char *buf)
 {
        size_t len;
+       char task_comm[TASK_COMM_LEN];
 
        len = sprintf(buf, "_PID=%d", task_tgid_nr(current)) + 1;
        len += sprintf(buf + len, "_TID=%d", task_pid_nr(current)) + 1;
        memcpy(buf + len, "_COMM=", 6);
        len += 6;
-       get_task_comm(buf + len, current);
+       get_task_comm(task_comm, current);
+       strcpy(buf + len, task_comm);
        while (buf[len] != '\0')
                len++;
        return len;