On Fri, Aug 09, 2024 at 10:10:40PM +0200, Christian Brauner wrote: > fcntl()s and file leases can just allocate on demand easily. Cleanup > happens during __fput() when file was really opend. For fcntl()s and > file leases this is guaranteed because the file is already alive. For > drivers they need to cleanup the allocated memory before they've > succesfully finished ->open(). Afterwards we'll just clean it up. > > Interactions with O_PATH should be fine as well e.g., when opening a > /dev/tty as O_PATH then no ->open() happens thus no filp->f_owner is > allocated. That's fine as no file operation will be set for those and > the device has never been opened. fcntl()s called on such things will > just allocate a ->f_owner on demand. Although I have zero idea why'd you > care about f_owner on an O_PATH fd. One general note: IMO you are far too optimistic about the use of __cleanup extensions; it's _not_ something that we want blindly used all over the place. In some cases it's fine, but I'm very nervous about the possibility of people starting to cargo-cult it all over the place. Again, __cleanup support in gcc has significant holes, at least up to gcc 12. This is *NOT* a generally safe part of C dialect we are using. And the pitfalls associated with it are not documented, let alone generally understood.