int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
                        struct pid *pid, struct task_struct *task)
 {
-       unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
        struct mm_struct *mm = get_task_mm(task);
 
        if (mm) {
+               unsigned long size;
+               unsigned long resident = 0;
+               unsigned long shared = 0;
+               unsigned long text = 0;
+               unsigned long data = 0;
+
                size = task_statm(mm, &shared, &text, &data, &resident);
                mmput(mm);
-       }
-       /*
-        * For quick read, open code by putting numbers directly
-        * expected format is
-        * seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n",
-        *               size, resident, shared, text, data);
-        */
-       seq_put_decimal_ull(m, "", size);
-       seq_put_decimal_ull(m, " ", resident);
-       seq_put_decimal_ull(m, " ", shared);
-       seq_put_decimal_ull(m, " ", text);
-       seq_put_decimal_ull(m, " ", 0);
-       seq_put_decimal_ull(m, " ", data);
-       seq_put_decimal_ull(m, " ", 0);
-       seq_putc(m, '\n');
 
+               /*
+                * For quick read, open code by putting numbers directly
+                * expected format is
+                * seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n",
+                *               size, resident, shared, text, data);
+                */
+               seq_put_decimal_ull(m, "", size);
+               seq_put_decimal_ull(m, " ", resident);
+               seq_put_decimal_ull(m, " ", shared);
+               seq_put_decimal_ull(m, " ", text);
+               seq_put_decimal_ull(m, " ", 0);
+               seq_put_decimal_ull(m, " ", data);
+               seq_put_decimal_ull(m, " ", 0);
+               seq_putc(m, '\n');
+       } else {
+               seq_write(m, "0 0 0 0 0 0 0\n", 14);
+       }
        return 0;
 }