extern void put_pid(struct pid *pid);
 extern struct task_struct *pid_task(struct pid *pid, enum pid_type);
+static inline bool pid_has_task(struct pid *pid, enum pid_type type)
+{
+       return !hlist_empty(&pid->tasks[type]);
+}
 extern struct task_struct *get_pid_task(struct pid *pid, enum pid_type);
 
 extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
 
  */
 static void pidfd_show_fdinfo(struct seq_file *m, struct file *f)
 {
-       struct pid_namespace *ns = proc_pid_ns(file_inode(m->file));
        struct pid *pid = f->private_data;
-       pid_t nr = pid_nr_ns(pid, ns);
+       struct pid_namespace *ns;
+       pid_t nr = -1;
 
-       seq_put_decimal_ull(m, "Pid:\t", nr);
+       if (likely(pid_has_task(pid, PIDTYPE_PID))) {
+               ns = proc_pid_ns(file_inode(m->file));
+               nr = pid_nr_ns(pid, ns);
+       }
+
+       seq_put_decimal_ll(m, "Pid:\t", nr);
 
 #ifdef CONFIG_PID_NS
-       seq_put_decimal_ull(m, "\nNSpid:\t", nr);
-       if (nr) {
+       seq_put_decimal_ll(m, "\nNSpid:\t", nr);
+       if (nr > 0) {
                int i;
 
                /* If nr is non-zero it means that 'pid' is valid and that
                 * Start at one below the already printed level.
                 */
                for (i = ns->level + 1; i <= pid->level; i++)
-                       seq_put_decimal_ull(m, "\t", pid->numbers[i].nr);
+                       seq_put_decimal_ll(m, "\t", pid->numbers[i].nr);
        }
 #endif
        seq_putc(m, '\n');