proc: Fix unbalanced hard link numbers
authorTakashi Iwai <tiwai@suse.de>
Fri, 28 Apr 2017 13:00:15 +0000 (15:00 +0200)
committerEric W. Biederman <ebiederm@xmission.com>
Sat, 29 Apr 2017 02:05:26 +0000 (21:05 -0500)
proc_create_mount_point() forgot to increase the parent's nlink, and
it resulted in unbalanced hard link numbers, e.g. /proc/fs shows one
less than expected.

Fixes: eb6d38d5427b ("proc: Allow creating permanently empty directories...")
Cc: stable@vger.kernel.org
Reported-by: Tristan Ye <tristan.ye@suse.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
fs/proc/generic.c

index ee27feb34cf4d50fc867dc138198c2da9cd7d9ef..9425c0d97262b548d8c8fbf7ce222cbad6e1ef58 100644 (file)
@@ -472,6 +472,7 @@ struct proc_dir_entry *proc_create_mount_point(const char *name)
                ent->data = NULL;
                ent->proc_fops = NULL;
                ent->proc_iops = NULL;
+               parent->nlink++;
                if (proc_register(parent, ent) < 0) {
                        kfree(ent);
                        parent->nlink--;