Re: [PATCH v2] proc: only bump parent nlink when registering directories

From: Krzysztof Wilczyński

Date: Mon Jun 29 2026 - 01:43:07 EST


Hello,

> > proc_register() increments the parent directory's link count for every
> > entry it registers, while remove_proc_entry() and remove_proc_subtree()
> > decrement it only when the removed entry is a directory. Regular files
> > thus inflate the parent's count while they exist, and leak one link
> > permanently on every create and remove cycle.
> >
> > For example, /proc/bus/pci/00 with twenty-two device files and no
> > subdirectories reports nlink 24 instead of 2, and SR-IOV VF enable
> > and disable cycles, each creating and removing the VF config space
> > entries under /proc/bus/pci/<bus>, inflate the link count of that
> > directory without bound.
> >
> > [...]
>
> Applied to the vfs.fixes branch of the vfs/vfs.git tree.
> Patches in the vfs.fixes branch should appear in linux-next soon.
[...]
> [1/1] proc: only bump parent nlink when registering directories
> https://git.kernel.org/vfs/vfs/c/552864f6ac8f

I assume this got lost? Seems its missing from 7.2-rc1, sadly.

Thank you!

Krzysztof